ada

Overloading operator “=” for anonymous access types?

孤人 提交于 2020-01-02 04:30:13
问题 I am working my way through Barnes' excellent Ada book. This is a code sample for deep comparison of linked lists from section 11.7: type Cell is record Next: access Cell; Value: Integer; end record; function "=" (L, R: access Cell) return Boolean is begin if L = null or R = null then -- universal = return L = R; -- universal = (Line A) elsif L.Value = R.Value then return L.Next = R.Next; -- recurses OK (Line B) else return False; end if; end "="; I can't seem to wrap my head around why in

Ada: packaging concepts [closed]

醉酒当歌 提交于 2019-12-31 03:39:10
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . This is a follow up of my earlier post here: Ada: Understanding private types and understanding packaging An implementation for the Rectangular type was made using one implementation i.e. Rectangular_Method_1 and a specification file and a body file were required for this

How to use GTK+ with ada

Deadly 提交于 2019-12-31 02:37:06
问题 Anyone can show me some examples, simple, how to use GTK with Ada? examples, like: How to use Glade with Ada, create an simple window.... an simple window, like this: #include <gtk/gtk.h> int main(int argc, char *argv[] ) { GtkWidget *window; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_show (window); gtk_main (); return 0; } And, It's possible to use GtkMM, with ada ? Thanks... 回答1: A few of my favorite GtkAda programs: Animation demo Linxtris Mine

Ada 95: Modifying output of dictionary program

放肆的年华 提交于 2019-12-30 10:08:48
问题 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

Ada 95: Modifying output of dictionary program

点点圈 提交于 2019-12-30 10:07:13
问题 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

Read input from a pipe in Ada

China☆狼群 提交于 2019-12-25 18:35:36
问题 I have a piece of code (see below) that reads data from a file given as a command line argument. I would like to add a support for being able to read the input from a pipe. For instance, the current version reads the data as main <file_name> , whereas it should also be possible to do something line cmd1 | main . Here is the source to read data from file: procedure main is File : Ada.Text_IO.File_Type; begin if Ada.Command_Line.Argument_Count /= 1 then return; else Ada.Text_IO.Open ( File =>

print an integer in ada83(Only) Not Ada95

不羁的心 提交于 2019-12-25 12:11:11
问题 I am trying to print an integer in Ada83 .All the web sites have the info regarding Ada95 way of printing i.e Integer_Text_IO.Put (C); but this does not get compiled in Ada83. How Do I print an Integer in Ada83(Its a course requirement )? 回答1: Integer_Text_IO is an instantiation of Integer_IO , provided in the standard library in Ada 95. In Ada 83, the generic package Integer_IO exists; you just have to instantiate it yourself. (You can also use Integer'Image , but that adds an annoying

Error: cannot generate code for file random.ads (package spec)

我与影子孤独终老i 提交于 2019-12-25 09:49:08
问题 I somehow cannot compile (neither run) my Ada code in GPS. I get an error: cannot generate code for file random.ads (package spec) gprbuild: *** compilation phase failed The random.ads file looks like this: with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; package random is protected randomOut is procedure Inicializal; entry Parcel( randomout: out Positive; from: in Positive; to: in Positive := 1 ); private G: Generator; Inicializalt: Boolean := False; end randomOut; task print

Ada- raised Constraint_error : bad input for 'Value:

不想你离开。 提交于 2019-12-25 08:48:26
问题 I'm trying to use Integer'Value to convert a string to an Integer. This works fine for the first loop through a file, but after that I get a bad input for 'value (raised Constraint_Error. I was hoping someone could show me the error of my ways, so that I can convert the string to an integer on each loop. WITH Ada.Text_IO, Ada.Integer_Text_IO; USE Ada.Text_IO, Ada.Integer_Text_IO; PROCEDURE Isbntest IS FUNCTION Strip(The_String: String; The_Characters: String) RETURN String IS Keep: ARRAY

Ada: Adding an exception in a separate procedure when reading a file

你。 提交于 2019-12-25 05:11:48
问题 This is a follow-up of this question: Ada: reading from a file . I would like to add an exception that checks if the file that I'm opening actually exists or not. I have made a separate procedure to avoid code clutter. Here is the main code test_read.adb : with Ada.Text_IO; use Ada.Text_IO; with Ada.Long_Float_Text_IO; with Ada.Float_Text_IO; procedure Test_Read is Input_File : File_Type; Value : Long_Float; procedure Open_Data (File : in Ada.Text_IO.File_Type; Name : in String) is separate;