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:16:00 -0800 Organization: http://groups.google.com Message-ID: <1165817760.736164.218530@73g2000cwn.googlegroups.com> References: <1165371252.358817.57840@80g2000cwy.googlegroups.com> <4577dc92$1_1@glkas0286.greenlnk.net> <7ft8le.vk1.ln@hunter.axlog.fr> 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 1165817765 17029 127.0.0.1 (11 Dec 2006 06:16:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 Dec 2006 06:16:05 +0000 (UTC) In-Reply-To: <7ft8le.vk1.ln@hunter.axlog.fr> 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:7878 Date: 2006-12-10T22:16:00-08:00 List-Id: 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 type= T > > has an anonymous type as an index range. I think it is better to avoid > > 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