From: Shark8 <onewingedshark@gmail.com>
Cc: mailbox@dmitry-kazakov.de
Subject: Re: Interresting, possibly buggy behavior in GNAT generics w/ expression function.
Date: Fri, 29 Mar 2013 09:43:35 -0700 (PDT)
Date: 2013-03-29T09:43:35-07:00 [thread overview]
Message-ID: <64b868ed-6e6e-4bc9-97ca-72ed20fc5a54@googlegroups.com> (raw)
In-Reply-To: <1ex3dm2hk2j54$.1uiyljwziv0hi$.dlg@40tude.net>
On Friday, March 29, 2013 10:21:39 AM UTC-6, 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.
I'm not sure I believe that [they are too weak] -- in any case this isn't a problem of the weakness of generics, it's a case of the compiler choosing a function which it should not dependent upon information it should not "know".
Keeping the instantiation of
Package Margins is new Generic_Attribute_Set(
Attribute_Name => "margin-left",
Attribute_Values => Integer, --J,
Attribute_Units => Screen,
Units => Units
);
altering the profile of Image [in the generic]
from: Function Image(Value : Positive) Return String is
to: Function Image(Value : Natural) Return String is
alters the behavior
from: margin-left="88%"
to: margin-left="884"
The issue disappears entirely if an enumeration is supplied for attribute_values so that the correct Image is chosen in either case of Image/Natural or Image/Positive.
>
> 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;
>
That's a good point, perhaps you should submit an AI?
next prev parent reply other threads:[~2013-03-29 16:43 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 [this message]
2013-03-29 17:43 ` Eryndlia Mavourneen
2013-03-29 17:45 ` Eryndlia Mavourneen
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