From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,66423c08b54dd4a3 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: about abstract data types and pointer Date: 1996/09/24 Message-ID: <3247DB70.64F4@gsfc.nasa.gov>#1/1 X-Deja-AN: 185026715 references: content-type: text/plain; charset=us-ascii organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA mime-version: 1.0 reply-to: Stephen.Leake@gsfc.nasa.gov newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; U) Date: 1996-09-24T00:00:00+00:00 List-Id: Benoit Rochefort wrote: > > Hi! I'm new with ADA but i'm a programmer since a long time. > > I use the ADA83 standard (but with the gnat compiler than can compile > ADA95). Most of what you want is available in Ada95, but not in Ada83. See the Ada95 reference manual and rational, on-line at: http://lglsun.epfl.ch/Ada/ Another good reference is "Ada as a Second Language", by Norman Cohen, available at good bookstores. > 1- Is there a way to define a procedure type like in MODULA-2 in > a way such: > > TYPE PROC IS PROCEDURE(IN E:ELEMENT); only in Ada 95 (since you don't want Ada83 generics). See LRM 3.10, access to subprogram types. > 2- Is there a way to totally hide the representation of an abstract > data type in the specification package? This is possible in Ada 83: package Abstraction is type Hidden is private; private type Totally_Hidden; type Hidden is access Totally_Hidden; end Abstraction; package body Abstraction is type Totally_Hidden is record ... end record; end Abstraction; The full declaration of type Totally_Hidden can be defered to the body, since the clients of Abstraction only need to know that type Hidden is a pointer. > > 3- Is there a way to "add" or change attributes to a new type that i > have elaborated as an abstract data type (in a package). > > Ex: L'First could have another meaning here if L is a List. > List'Nb could denote the number of elements of a List L. > > I know i can (and sure i must) code these as functions but i just > want to use them as attribute; which could be much more natural here. > > Is that what RENAMES is for? In Ada95, the compiler vendor can define new attributes, and you can provide new functions for any defined attributes, but you can't define your own new attributes. In Ada83, you cannot provide new functions for attributes. > 4- Is there a way to overload the ":=" operator if List is a > limited private type? Not in Ada83. In Ada95, you can derive a type from Controlled, and then define the subprograms Initialize, Adjust, and Finalize, which are called at appropriate times during assignment. This turns out to be better structured than directly overloading ":=". See Chapter 12.5 in "Ada as a Second Language", or LRM 7.6 > 5- Do the ADA83 standard specify that the deallocation of memory is > automatically done? Or must I ensure that my program does it? Ada83 and Ada95 both allow the compiler vendor to implement garbage collection (I don't know of any that do). You can implement your own via Unchecked_Deallocation. > > 6- Now the easy one. > Is there a function or procedure to read a character on the > keyboard without the need to press enter WHICH IS DEFINED ON THE > STANDARD (independant of the used compiler and machine). No. In Ada95, Text_IO.Get_Immediate is recommended (but not required) to have this behaviour. I believe the latest version of gnat implements it this way on most platforms. > > I know that's a lot of questions to answer but that would be VERY > appreciated. No problem; I learned a lot from reading this group, and I'm pleased to be able to return something. > > Please reply by mail. Thank you. Sorry, if you want to benefit from the community, you have to be a member! > Benoit Rochefort > jk791840@er.uqam.ca -- - Stephe Stephen.Leake@gsfc.nasa.gov