comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Interfaces and private types
Date: Mon, 28 Jan 2008 16:58:25 -0600
Date: 2008-01-28T16:58:25-06:00	[thread overview]
Message-ID: <fnlmms$28q$1@jacob-sparre.dk> (raw)
In-Reply-To: fnl2in$k49$1@news2.u-psud.fr

"Philippe Tarroux" <philippe.tarroux@limsi.fr> wrote in message
news:fnl2in$k49$1@news2.u-psud.fr...
> Hi again,
>
> There is no compilation problem with the following code :
>
> package Test_Interfaces is
>
>    type Int is synchronized interface;
>    procedure Init (I : in out Int) is abstract;
>
>    type T is new Int with private;
>
> private
>
>    task type T is
>       entry Init;
>    end T;
> end Test_Interfaces;

As written, this is illegal because type T does not have the interface Int.
Specifically, it violates 7.3(7.3/2): "the partial view shall be a
descendant of an interface type (see 3.9.4) if and only if the full type is
a descendant of the interface type."

Assuming that this is just a mistake in your interface and you meant

   task type T is new Int with

then your program is legal, and you should complain your your compiler
vendor about the bug. In no case should there be an error on the declaration
of the object, so that makes it pretty clear that there is a compiler bug.

You could work around the bug with something like:

package Test_Interfaces is

   type Int is synchronized interface;
   procedure Init (I : in out Int) is abstract;

   type T is new Int with private;
   overriding procedure Init (I : in out T);

private

   task type T is new Int with
      entry Init;
   end T;
end Test_Interfaces;

and then have
    procedure Init (I : in out T) is
    begin
          I.Init;
    end Init;
in the body. (But note that this runs into a known bug in the Ada standard,
so it isn't clear that the code will work right.)

                              Randy.










  parent reply	other threads:[~2008-01-28 22:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-28 17:16 Interfaces and private types Philippe Tarroux
2008-01-28 18:21 ` Georg Bauhaus
2008-01-28 22:58 ` Randy Brukardt [this message]
2008-01-29  9:35   ` Philippe Tarroux
2008-01-29 12:48     ` Georg Bauhaus
2008-01-29 13:08       ` Philippe Tarroux
2008-01-29 23:29     ` Randy Brukardt
replies disabled

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