Re: Interfaces and private types



Randy Brukardt wrote:
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."
As written, this is illegal because type T does not have the interface Int.
As it is written the compiler i use doesn't mention any error and i interpreted this construct as legal because :

1/ the interface is synchronized thus allowing to derive concurrent or non concurrent types
2/ The partial view is a descendant of the interface type
3/ The full view precises that the partial view correspond to a concurrent type but hides this detail to the user

Writing, as you propose

task type T is new Int with private;

tells the user that T is a concurrent type, what precisely i wanted to avoid.
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.)
But the overriding procedure Init needs to be redefined both as an entry of T and as a procedure. I assume that when i will be trying to call O.Init with O a type T task there will be a mistake due to the double definition.

But, anyway, thanks a lot for the comments. I am waiting for comments from the guys who are in charge of the gnat compiler.

Philippe Tarroux
.



Relevant Pages

  • Re: Interfaces and private types
    ... procedure Init (I: in out Int) is abstract; ... this is illegal because type T does not have the interface Int. ... so that makes it pretty clear that there is a compiler bug. ...
    (comp.lang.ada)
  • 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. ... declaration of T in the private part as the private T does not ...
    (comp.lang.ada)
  • 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. ... declaration of T in the private part as the private T does not ...
    (comp.lang.ada)
  • 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)
  • [PATCH 3/7] adding xc5000 tuner chip driver
    ... this code also uses the tunerchip.h interface which allows to attach ... It uses the latest Xceive reference driver which fixes some issues. ... new file mode 100644 ... unsigned int frequency; ...
    (Linux-Kernel)