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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,910a48a538936849 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!73g2000cwn.googlegroups.com!not-for-mail From: "markww" Newsgroups: comp.lang.ada Subject: Re: how to import a package Date: 10 Dec 2006 22:50:04 -0800 Organization: http://groups.google.com Message-ID: <1165819804.449958.305980@73g2000cwn.googlegroups.com> References: <1165371252.358817.57840@80g2000cwy.googlegroups.com> <4577dc92$1_1@glkas0286.greenlnk.net> <7ft8le.vk1.ln@hunter.axlog.fr> <1165817760.736164.218530@73g2000cwn.googlegroups.com> NNTP-Posting-Host: 68.174.181.181 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1165819809 25881 127.0.0.1 (11 Dec 2006 06:50:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 Dec 2006 06:50:09 +0000 (UTC) In-Reply-To: <1165817760.736164.218530@73g2000cwn.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 73g2000cwn.googlegroups.com; posting-host=68.174.181.181; posting-account=cNKOMg0AAADT2ug8oGSYYXo8bsDvrHzw Xref: g2news2.google.com comp.lang.ada:7879 Date: 2006-12-10T22:50:04-08:00 List-Id: Ok I removed the 'access' keyword for the Next_Rec/Prev_Rec definitions and that seems to have cleared that issue up. I hope this is the last problem I run into , the rest of the app is compiling ok. I used to have a procedure that would add a person_rec to my linked list. I'm trying to update it so it takes a generic type and gets added to the linked list instead. So I made a test function like: procedure Add_Record(GenericData : gNode.T) is Temp : gNode.Node_Ptr; begin Temp :=3D new gNode.Node; Temp.Data :=3D GenericData; end Add_Record; now the compiler is saying that my generic type T is not visible to the rest of the application. It's in the imported package though and all the rest of the parts are visible. How do I make it visible? Also, is this procedure definition correct? In C++ it's easy to do this after defining a type it would be just: bool Add_Record (T t); template bool CLinkedList::Add_Record(T t) { // ... } I'm guessing it must be similar. Thanks, Mark markww wrote: > Ok I still don't understand why this assignment is illegal though - > here's a test I have: > > generic > type T is private; > package GenericNode is > type Node; > type Node_Ptr is access Node; > type Node is record > Data : T; -- the generic data we want to > store in a node. > Prev_Rec : access Node_Ptr; -- points to the next record or > null if none exists. > Next_Rec : access Node_Ptr; -- points to the previous > record or null if none exists. > end record; > end GenericNode; > > now later... > > package gNode is new GenericNode(T =3D> PERSON_REC); > use gNode; > > function Test(whatever : INTEGER) return INTEGER is > Temp : gNode.Node_Ptr; > begin > Temp :=3D Temp.Next_Rec; -- no!!!!!!!!!!!!!!!! > return 0; > end Test; > > Why is the Temp assignment not possible? The compiler says: expected > type Node_Ptr defined in genericnode.ads. But I have defined it as type > Node_Ptr. > > Thanks, > Mark > > > > Jean-Pierre Rosen wrote: > > Stuart a =E9crit : > > > package body P is > > > type T is array(0..5) of integer; > > > A, B : array(0..5) of integer; > > > C, D : T; > > > begin > > > A :=3D B; > > > -- Not allowed because types don't match! > > > C :=3D D; > > > -- Types match! > > > end P; > > > > > > [...] > > > However, both C and D are of the same named type - even though the ty= pe T > > > has an anonymous type as an index range. I think it is better to avo= id > > > anonymous types - so the declaration of T might be better written as: > > > type T_index is range 0..5; > > > type T is array(T_index) of integer; > > > > > Just nit-picking, the index type of T is not anonymous, it is > > Standard.Integer by default, therefore the aboved declaration is not > > equivalent. > > > > Agreed, it is best to avoid hidden use of Standard.Integer. If you need > > Integer as the index type, better use: > > type T is array (Integer range 0..5) of Integer; > > > > Note that this remark is also applicable to loops. Rather than: > > for I in 1..10 loop > > > > write: > > for I in Integer range 1..10 loop > > > > (small plug: there is a rule in AdaControl to check the above) > > -- > > --------------------------------------------------------- > > J-P. Rosen (rosen@adalog.fr) > > Visit Adalog's web site at http://www.adalog.fr