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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,556e5b18154df788 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.110.68 with SMTP id m4mr2553773qap.2.1364578985497; Fri, 29 Mar 2013 10:43:05 -0700 (PDT) X-Received: by 10.49.86.40 with SMTP id m8mr234174qez.30.1364578985463; Fri, 29 Mar 2013 10:43:05 -0700 (PDT) Path: v17ni11qad.0!nntp.google.com!t2no25895163qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 29 Mar 2013 10:43:05 -0700 (PDT) In-Reply-To: <1ex3dm2hk2j54$.1uiyljwziv0hi$.dlg@40tude.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.59.115.2; posting-account=7Oy7OQoAAABhVYFOo553Cn1-AaU-bSfl NNTP-Posting-Host: 129.59.115.2 References: <1k6ipbtagwzw4$.1dv47rfygcedg.dlg@40tude.net> <1ex3dm2hk2j54$.1uiyljwziv0hi$.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Interresting, possibly buggy behavior in GNAT generics w/ expression function. From: Eryndlia Mavourneen Cc: mailbox@dmitry-kazakov.de Injection-Date: Fri, 29 Mar 2013 17:43:05 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-03-29T10:43:05-07:00 List-Id: On Friday, March 29, 2013 11:21:39 AM UTC-5, Dmitry A. Kazakov wrote: > On Fri, 29 Mar 2013 14:45:33 +0000, Simon Wright wrote: >=20 >=20 >=20 > > "Dmitry A. Kazakov" writes: >=20 > >=20 >=20 > >> On Fri, 29 Mar 2013 07:45:04 +0000, Simon Wright wrote: >=20 > >> >=20 > >>> I don't know whether this is a language problem >=20 > >> >=20 > >> It is a general language problem that generic specifications and bodie= s >=20 > >> cannot be fully checked. Matched formal parameters only is not suffici= ent. >=20 > >> Much better than with C++ templates, but still same mess. >=20 > >=20 >=20 > > But, do you think it should have failed at instantiation? >=20 >=20 >=20 > It should fail to compile, instantiation time is too late. Generic >=20 > contracts are much too weak. >=20 >=20 >=20 > For example: >=20 >=20 >=20 > generic >=20 > type S is new T with private; >=20 > package P is >=20 > type Q is new S with null record; >=20 > not overriding procedure Foo (X : Q); >=20 > =20 >=20 > It is uncheckable if S does not have Foo already. Thus, this must be a >=20 > compile error. >=20 >=20 >=20 > If we wanted properly contracted generics (personally, I don't care), we >=20 > would need some syntax to tell that S may not have operation Foo, e.g. >=20 >=20 >=20 > generic >=20 > type S is new T with private; >=20 > not with procedure Foo (X : S); >=20 > package P is >=20 > type Q is new S with null record; >=20 > not overriding procedure Foo (X : Q); -- We know S does not have this >=20 >=20 >=20 > --=20 >=20 > Regards, >=20 > Dmitry A. Kazakov >=20 > http://www.dmitry-kazakov.de I agree that generics are too weak. It seems that I frequently am trying t= o use a generic formal parameter's characteristics, but the compiler remind= s me that the characteristic is unknown (until instantiation), and so the c= ompilation of the generic fails. Indices are a good example. I am not sur= e about 'Range. That might work. -- Eryndlia