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,FROM_NUMERIC_TLD autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,910a48a538936849 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!83.128.0.11.MISMATCH!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!193.111.200.220.MISMATCH!news-peer.gradwell.net!news-peer-lilac.gradwell.net!not-for-mail From: "Stuart" Newsgroups: comp.lang.ada References: <1165371252.358817.57840@80g2000cwy.googlegroups.com><1165449396.112251.129200@l12g2000cwl.googlegroups.com><1165464845.649851.312700@79g2000cws.googlegroups.com> Subject: Re: how to import a package Date: Thu, 7 Dec 2006 09:32:11 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original Message-ID: <4577dc92$1_1@glkas0286.greenlnk.net> X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Host: 20.133.0.1 X-Trace: 1165483941 news.gradwell.net 624 dnews/20.133.0.1:11418 X-Complaints-To: news-abuse@gradwell.net Xref: g2news2.google.com comp.lang.ada:7845 Date: 2006-12-07T09:32:11+00:00 List-Id: "Brian May" wrote in message news:sa4veko5ndy.fsf@margay.local... >>>>>> "markww" == markww writes: > Going back in time, you said you defined Next_Rec as: > > type Node; > type Node_Ptr is access Node; > type Node is record > Data : T; > Prev_Rec : access Node; > Next_Rec : access Node; > end record; > > Note that "access Node" is not the same thing as "Node_Ptr". > > From memory the first is an "anonymous access type", but my memory is > a bit rusty on this topic right now (Ada 2005 feature when used in a > record?). Ada is very particular about type matching and this can lead to some consequences that, at first, appear very odd. If you look at this example: package P is pragma Elaborate_Body(P); -- Allow a package body to exist! end P; package body P is type T is array(0..5) of integer; A, B : array(0..5) of integer; C, D : T; begin A := B; -- Not allowed because types don't match! C := D; -- Types match! end P; Even though A and B appear in the same statement, they are of different anonymous types. This is because A, B : array(0..5) of integer; is equivalent to A : array(0..5) of integer; B : array(0..5) of integer; and, as you may already have realized, homographs are not treated as being the same in Ada. 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; -- Stuart