ada

Why does an Ada compiler let range violations pass? Why is my type declaration a runtime entity?

我的梦境 提交于 2019-12-02 00:42:12
问题 Why does Ada compiler let range violations pass? It does give warning, but why does it let it pass if it is an error in any case? Is there a practical scenario in which this is a useful behaviour? And most importantly: Why is type declaration a runtime entity? I mean the 3rd line of the code example is something I expect to be evaluated ahead of time. I thought that only the 5th line will "make it" into the executable. Why not? Is that something useful? Am I missing or misinterpreting

Ada: Understanding private types and understanding packaging

痴心易碎 提交于 2019-12-02 00:01:37
I am trying to learn how to use private declarations in Ada and also to understand packaging. I have tried to keep my codes as short as possible. We start with the main file rectangular_Form.ads with Rectangular_Method_1; package Rectangular_Form renames Rectangular_Method_1; -- with Rectangular_Method_2; -- package Rectangular_Form renames Rectangular_Method_2; This tells us that we can have two implementations and that for now Rectangular_Method_1 has been chosen. Then we have the specifications file Rectangular_Method_1.ads : package Rectangular_Method_1 is type Rectangular is private;

Ada: plotting 2d graphs

二次信任 提交于 2019-12-01 23:45:57
it would be interesting to be able to plot a 2D graph within an Ada code rather than having to save values say to file and use an external drawing software afterwards. A search on the web has taken me to two packages: Win_IO and JEWL. I have been able to use WIN_IO though but the documentation is quite poor and having just started using it, it seems that it is not possible to resize the size of the canvas. I use the GPS editor and I get complaint when running Win_IO that some fonts are not available on my system and that the output will be ugly. Finally the plot doesn't itself pop up on the

Derived types and sub types in Ada

跟風遠走 提交于 2019-12-01 17:47:49
What are the differences? First of all, terminology: it's "Ada", not "ADA" -- it's named after "Ada Lovelace"; it is not an acronym. A subtype is compatible with its base type, so you can mix operands of the base type with operands of the base type. For example: subtype Week_Days is Integer range 1..7; Since this is a subtype, you can (for example) add 1 to a weekday to get the next weekday. A derived type is a completely separate type that has the same characteristics as its base type. You cannot mix operands of a derived type with operands of the base type. If, for example, you used: type

gcc, make: how to disable fail on warning?

浪子不回头ぞ 提交于 2019-12-01 14:19:52
问题 I'm trying to build gcc for use with an AVR micro controller and avr-ada, and I've hit a roadblock caused by my regular compiler being too picky about the version I needed for the AVR. I get the following warning, which in turn causes the gcc or make to report an error: gcc -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada -I../../gcc/ada ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o exp_ch5.adb:177:16: warning: function "Has_Address_Clause" is not referenced make[2]: *** [ada/exp_ch5.o] Error 1

Access type declaration effect on deallocation

微笑、不失礼 提交于 2019-12-01 12:45:50
Is the memory freed the same way after the declare block (and before the end of the procedure of course) in both cases: procedure allocation is type T_Integer_Access is access Integer; begin declare P : T_Integer_Access; begin P := new Integer'(5); end; end; procedure allocation is begin declare type T_Integer_Access is access Integer; P : T_Integer_Access; begin P := new Integer'(5); end; end; Put another way, has the access type declaration an effect on memory deallocation? There’s a good chance that the storage pool (memory arena) from which objects of type T_Integer_Access is allocated won

Ada 95: Modifying output of dictionary program

依然范特西╮ 提交于 2019-12-01 06:52:06
I've found this dictionary by William Whitaker on the Internet and I like its parsing capabilities . But the output doesn't fit for me. The issue (challenge for me): Given an input form such as "audiam", the program returns the following output (plain text): audi.am V 4 1 PRES ACTIVE SUB 1 S audi.am V 4 1 FUT ACTIVE IND 1 S audio, audire, audivi, auditus V (4th) [XXXAO] hear, listen, accept, agree with; obey; harken, pay attention; be able to hear; But I just want to receive the following text output (same input: audiam): audiam=audio, audire, audivi, auditus That is: InputWord=Dictionary

Does anyone know of an Ada plugin for protocol buffers?

假如想象 提交于 2019-12-01 06:25:40
问题 I'm looking for an Ada plugin for protocol buffers. Looks like there is just about any language plugin available or in the works except for Ada. 回答1: Well, the only thing I found is this thesis. Unfortunately, I did not find any source code for a translation tool, i.e. what you name a plugin . The only thing I can tell is that the tool was developed in C++. UPDATE There's finally an Ada implementation for Protocol Buffers. It has been developed by Per Sandberg and is available on GitHub. I

Is there a “this” keyword in Ada?

女生的网名这么多〃 提交于 2019-12-01 05:37:28
问题 Specifically, is there a way for a task to get a reference to itself? For example: task type someTask; type someTaskAccessor is access someTask; task body someTask is pointerToTask : someTaskAccessor; begin pointerToTask = this; end someTask; 回答1: the most evident solution i could suggest is to declare a rendez-vous (an entry) at the very beginning of your task, to which you pass a reference to the task just created. the other possibility is using a discriminant to your task type, whose role

Dynamic dispatching in Ada

大兔子大兔子 提交于 2019-12-01 04:31:42
问题 I am having trouble getting dynamic dispatching to work, even with this simple example. I believe the problem is in how i have set up the types and methods, but cannot see where! with Ada.Text_Io; procedure Simple is type Animal_T is abstract tagged null record; type Cow_T is new Animal_T with record Dairy : Boolean; end record; procedure Go_To_Vet (A : in out Cow_T) is begin Ada.Text_Io.Put_Line ("Cow"); end Go_To_Vet; type Cat_T is new Animal_T with record Fur : Boolean; end record;