comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: GNAT GPL 2009 - issue with floating points?
Date: Mon, 12 Oct 2009 18:26:54 -0500
Date: 2009-10-12T18:26:54-05:00	[thread overview]
Message-ID: <hb0e32$20c$1@munin.nbi.dk> (raw)
In-Reply-To: 1y6imbz0dijq$.1ofvdwq3q3cz7.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:1y6imbz0dijq$.1ofvdwq3q3cz7.dlg@40tude.net...
> On Sun, 11 Oct 2009 11:33:04 +0200, Dirk Herrmann wrote:
>
>> Dmitry A. Kazakov wrote:
>>> On Sat, 10 Oct 2009 08:39:47 +0200, Damien Carbonne wrote:
>>>
>>>> Thanks, now things are clearer. I understand that the compiler can not
>>>> determine Real'Size when it compiles the generic package, but when it 
>>>> is
>>>> instantiated, it should have then necessary knowledge.
>>>
>>> Not if the generic body is shared, rather than expanded.
>>
>> It seems that the rules for generics are designed to allow sharing.
>
> They were.
>
> Presently, I don't know if shared / contracted model is any alive.
> Considering:
>
>   generic
>      type J is interface and I;
>   package P is
>      type T is new J with null record;
>   end P;
>
> When compiling P you cannot know if the actual for J does not have an
> abstract operation which T does not implement.

Right, but that is present in Ada 95 as well. That's why all rules are 
rechecked in the visible part of an instance. In this particular example, 
the generic is legal, but an instance could be illegal if an operation that 
requires overriding is inherited.

Note that type extensions like this are always illegal in generic unit 
bodies, so there is no problem with that. The basic principle (as described 
by the Ada 9x design team) is to "assume the best (and recheck)" in generic 
specs and "assume the worst" in generic bodies.

> Nevertheless one tries to pretend that generics still have some kind of
> "contracts".

The body has a strong contract, the specification a weaker one.

...
> Then the solution is wrong. The desire is not to share bodies, but to have
> contracts. With generics this goal is most likely unachievable.

Neverhteless, Ada achieves it. Of course, the Ada definition of a generic 
contract may not match your ideal...

                                     Randy.





      reply	other threads:[~2009-10-12 23:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-09 20:36 GNAT GPL 2009 - issue with floating points? Damien Carbonne
2009-10-09 21:06 ` Adam Beneschan
2009-10-09 22:15   ` Damien Carbonne
2009-10-09 22:44     ` Ludovic Brenta
2009-10-10  6:33       ` Damien Carbonne
2009-10-10 14:55       ` Samuel Tardieu
2009-10-10 16:12         ` Ludovic Brenta
2009-10-10 16:38         ` Damien Carbonne
2009-10-09 23:26     ` Adam Beneschan
2009-10-10  6:39       ` Damien Carbonne
2009-10-10  7:16         ` Dmitry A. Kazakov
2009-10-11  9:33           ` Dirk Herrmann
2009-10-11 10:27             ` Dmitry A. Kazakov
2009-10-12 23:26               ` Randy Brukardt [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox