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=-1.0 required=5.0 tests=BAYES_00,PLING_QUERY, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d74cdcee29b02bcc X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news.glorb.com!news.ecp.fr!oleane.net!oleane!not-for-mail From: "Tom Grosman" Newsgroups: comp.lang.ada Subject: Re: Discriminant ans tagged type ?! Date: Fri, 4 Apr 2008 17:40:37 +0200 Organization: Aonix Message-ID: References: <47dfde3d$0$26828$426a74cc@news.free.fr> <6d529059-8109-4b17-845e-2a6e1430321c@i7g2000prf.googlegroups.com> <25164625-2bf7-4cea-b4fa-dc1422588446@u72g2000hsf.googlegroups.com> <641eca48-f0c9-4ccd-a998-2de9a727bacb@u10g2000prn.googlegroups.com> NNTP-Posting-Host: 62.161.96.162 X-Trace: s1.news.oleane.net 1207321789 1953 62.161.96.162 (4 Apr 2008 15:09:49 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Fri, 4 Apr 2008 15:09:49 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Original Xref: g2news1.google.com comp.lang.ada:20802 Date: 2008-04-04T17:40:37+02:00 List-Id: "Tony" a �crit dans le message de news: cc37c7dc-d89b-4f4a-82e3-24941300efb5@k13g2000hse.googlegroups.com... > On 21 mar, 16:25, Adam Beneschan wrote: >> On Mar 21, 1:18 am, Tony wrote: >> >> >> >> > On 18 mar, 20:54, Adam Beneschan wrote: >> >> > > On Mar 18, 8:54 am, Adam Beneschan wrote: >> >> > > > However, I tried changing the declaration of T as follows: >> >> > > > T : String (1 .. B.L); -- NO, THIS IS WRONG, I SCREWED UP >> >> > > > and GNAT accepted it. (I haven't done enough testing to make sure >> > > > GNAT handles it correctly in other ways, though.) Here, B refers >> > > > to >> > > > the "current instance" of the type (8.6(17)), and 3.7(18) means >> > > > that >> > > > all instances of the type will have a component L that is inherited >> > > > from A, so this should be legal unless there are some other rules >> > > > that >> > > > I've missed (and that GNAT also missed). >> >> > > Never mind. After reading Bob's post, I got pointed to 3.8(10-12), >> > > which disallows references to inherited discriminants in a type >> > > extension. So I guess GNAT (or at least the version I'm using, which >> > > is probably not the latest) is wrong to accept this. Sorry. >> >> > > -- Adam >> >> > -- >> > I tried Bob's answer with the Aonix compiler: >> > ERROR : LRM:3.8(12), A discriminant used in a constraint may only >> > appear alone as a direct_name. >> > I'm lost...;-) >> >> 3.8(12) is one of the rules I overlooked (thanks, Tuck). Perhaps you >> tried Bob's answer together with my incorrect suggestion to use >> string(1..B.L), which violates that rule; when you use a discriminant >> in a constraint, the discriminant can't be an "expanded name" or part >> of a larger expression, and I think B.L is an expanded name here. My >> apologies for misleading you. >> >> This should work: >> >> type B (L : Natural) is new A(L) with record >> T : String (1 .. L); >> end record; >> >> Everything I said earlier about visibility wouldn't apply here, >> because redeclaring the discriminant L makes it visible inside the >> record declaration of B. This would work too: >> >> type B (Ell : Natural) is new A(L) with record >> T : String (1 .. Ell); >> end record; >> >> It's the new discriminant that can be used in the declaration, not the >> one inherited from A. >> >> > Is my first code correct? I guess yes... >> >> Still no. The compiler may accept it, but that just means the >> compiler has a bug. >> >> I hope I've got everything straight now. >> >> -- Adam > -- > You are right !! , it works :-) > Thanks for all. > Tony. > -- Tony, Thanks for bringing this problem to our attention. Tom Grosman, Aonix