Re: Interfaces and private types



"Philippe Tarroux" <philippe.tarroux@xxxxxxxx> wrote in message
news:fnl2in$k49$1@xxxxxxxxxxxxxxxxxx
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.







.



Relevant Pages

  • Re: Interfaces and private types
    ... descendant of an interface type if and only if the full type is ... this is illegal because type T does not have the interface Int. ... overriding procedure Init; ...
    (comp.lang.ada)
  • Difference between casting to a class and to an interface
    ... compiler doesn't give you error for the lines below.. ... error is Cannot convert type 'shape' to 'int' ... is there difference between casting to a class and casting to an interface ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: csharp language idea
    ... Unless those structs are ... I think that's better than the compiler making it ... Suppose the value type implements an interface which allows mutation. ... int X ...
    (microsoft.public.dotnet.languages.csharp)
  • Calling C++ from Fortran
    ... routines from Fortran. ... C++ compiler, option 1: ... FORTRAN interface specification ... int FillRandom; ...
    (comp.lang.fortran)
  • RFC: if_clone overhaul
    ... Please test/review the following patch to the network interface cloneing ... static void ... -if_clone_lookup(const char *name, int *unitp) ... static int gifmodevent; ...
    (freebsd-net)