From: Eryndlia Mavourneen <eryndlia@gmail.com>
Cc: mailbox@dmitry-kazakov.de
Subject: Re: Interresting, possibly buggy behavior in GNAT generics w/ expression function.
Date: Fri, 29 Mar 2013 10:45:37 -0700 (PDT)
Date: 2013-03-29T10:45:37-07:00 [thread overview]
Message-ID: <925edf59-aabd-4323-990d-0e7697adc7cf@googlegroups.com> (raw)
In-Reply-To: <f865a6aa-6da4-44a9-8a36-30c70f628281@googlegroups.com>
On Friday, March 29, 2013 12:43:05 PM UTC-5, Eryndlia Mavourneen wrote:
> 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:
>
> >
>
> >
>
> >
>
> > > "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
> >
>
> > >
>
> >
>
> > >> On Fri, 29 Mar 2013 07:45:04 +0000, Simon Wright wrote:
>
> >
>
> > >>
>
> >
>
> > >>> I don't know whether this is a language problem
>
> >
>
> > >>
>
> >
>
> > >> It is a general language problem that generic specifications and bodies
>
> >
>
> > >> cannot be fully checked. Matched formal parameters only is not sufficient.
>
> >
>
> > >> Much better than with C++ templates, but still same mess.
>
> >
>
> > >
>
> >
>
> > > But, do you think it should have failed at instantiation?
>
> >
>
> >
>
> >
>
> > It should fail to compile, instantiation time is too late. Generic
>
> >
>
> > contracts are much too weak.
>
> >
>
> >
>
> >
>
> > For example:
>
> >
>
> >
>
> >
>
> > generic
>
> >
>
> > type S is new T with private;
>
> >
>
> > package P is
>
> >
>
> > type Q is new S with null record;
>
> >
>
> > not overriding procedure Foo (X : Q);
>
> >
>
> >
>
> >
>
> > It is uncheckable if S does not have Foo already. Thus, this must be a
>
> >
>
> > compile error.
>
> >
>
> >
>
> >
>
> > If we wanted properly contracted generics (personally, I don't care), we
>
> >
>
> > would need some syntax to tell that S may not have operation Foo, e.g.
>
> >
>
> >
>
> >
>
> > generic
>
> >
>
> > type S is new T with private;
>
> >
>
> > not with procedure Foo (X : S);
>
> >
>
> > package P is
>
> >
>
> > type Q is new S with null record;
>
> >
>
> > not overriding procedure Foo (X : Q); -- We know S does not have this
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > Regards,
>
> >
>
> > Dmitry A. Kazakov
>
> >
>
> > http://www.dmitry-kazakov.de
>
>
>
> I agree that generics are too weak. It seems that I frequently am trying to use a generic formal parameter's characteristics, but the compiler reminds me that the characteristic is unknown (until instantiation), and so the compilation of the generic fails. Indices are a good example. I am not sure about 'Range. That might work.
>
>
>
> -- Eryndlia
I do realize, of course, that indices can be specified as formal parameters, but that is a lot of hassle. I seem to recall that there were other issues, too, that failed in compiling an generic unit.
-- Eryndlia
next prev parent reply other threads:[~2013-03-29 17:45 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 17:34 Interresting, possibly buggy behavior in GNAT generics w/ expression function Shark8
2013-03-28 18:06 ` Simon Wright
2013-03-28 18:38 ` Shark8
2013-03-30 5:59 ` Stephen Leake
2013-03-30 14:20 ` Shark8
2013-03-29 7:45 ` Simon Wright
2013-03-29 12:27 ` Dmitry A. Kazakov
2013-03-29 14:45 ` Simon Wright
2013-03-29 16:21 ` Dmitry A. Kazakov
2013-03-29 16:43 ` Shark8
2013-03-29 17:43 ` Eryndlia Mavourneen
2013-03-29 17:45 ` Eryndlia Mavourneen [this message]
2013-03-29 18:38 ` Simon Wright
2013-03-30 0:56 ` Randy Brukardt
2013-03-30 9:24 ` Dmitry A. Kazakov
2013-04-02 0:52 ` Randy Brukardt
2013-04-02 8:51 ` Dmitry A. Kazakov
2013-04-02 21:59 ` Randy Brukardt
2013-03-29 14:47 ` Shark8
2013-03-29 14:56 ` Shark8
2013-03-30 1:04 ` Randy Brukardt
2013-03-30 2:36 ` Shark8
2013-03-30 15:51 ` Simon Wright
2013-04-01 15:58 ` Adam Beneschan
2013-04-02 0:46 ` Randy Brukardt
2013-04-02 8:18 ` Simon Wright
2013-04-02 11:14 ` Stephen Leake
2013-04-02 22:00 ` Randy Brukardt
2013-04-02 23:01 ` Adam Beneschan
2013-04-04 0:08 ` Randy Brukardt
2013-03-29 14:47 ` Simon Wright
2013-03-29 14:54 ` Shark8
2013-03-29 15:26 ` Bill Findlay
2013-03-29 15:48 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox