From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: tagged primitive operation and freezing
Date: Sat, 13 Nov 2010 11:24:30 +0100
Date: 2010-11-13T11:24:30+01:00 [thread overview]
Message-ID: <878w0xr069.fsf@ludovic-brenta.org> (raw)
In-Reply-To: ab723ba2-d798-46e8-a0e6-0d2401cce19e@r31g2000prg.googlegroups.com
troll writes on comp.lang.ada:
> generic
> type Object_T is private;
> procedure blah ( Param : Object_T );
>
> -------
>
> with blah;
> package oops is
> type a is tagged null record; -- any tagged type
>
> -- must be a type extension to induce failure:
> type Flight_T is new a with null record; -- fail
>
> function b (Flight : in Flight_T) return String;
>
> procedure c is new blah (Object_T => Flight_T);
>
> end;
I think the reason why this is illegal is because c is a primitive
operation of Flight_T; at the same time, using Flight_T as an actual
generic parameter freezes Flight_T just before the declaration of this
new primitive operation. Therefore the declaration of c is illegal.
You can work around this by wrapping Flight_T in a package:
generic
type Object_T is private;
procedure blah ( Param : Object_T );
with blah;
package oops is
type a is tagged null record; -- any tagged type
package Flight is
-- must be a type extension to induce failure:
type T is new a with null record;
function b (Flight : in T) return String;
end Flight; -- this freezes Flight_T
procedure c is new blah (Object_T => Flight.T); -- non-primitive
end oops;
--
Ludovic Brenta.
next prev parent reply other threads:[~2010-11-13 10:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-13 3:24 tagged primitive operation and freezing troll
2010-11-13 10:24 ` Ludovic Brenta [this message]
2010-11-15 14:23 ` troll
2010-11-15 16:30 ` Adam Beneschan
2010-11-16 8:53 ` Ludovic Brenta
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox