comp.lang.ada
 help / color / mirror / Atom feed
From: troll <wisniewski.ru@gmail.com>
Subject: Re: tagged primitive operation and freezing
Date: Mon, 15 Nov 2010 06:23:44 -0800 (PST)
Date: 2010-11-15T06:23:44-08:00	[thread overview]
Message-ID: <076ebb12-e620-48b7-ab0f-cb90169d91b4@g4g2000prj.googlegroups.com> (raw)
In-Reply-To: 878w0xr069.fsf@ludovic-brenta.org

But only if it is tagged. untagged type, even though frozen, DOES
compile.

On Nov 13, 5:24 am, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> 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.- Hide quoted text -
>
> - Show quoted text -




  reply	other threads:[~2010-11-15 14:23 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
2010-11-15 14:23   ` troll [this message]
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