comp.lang.ada
 help / color / mirror / Atom feed
* Re: inheritance and private overiding
  2000-05-04  0:00 inheritance and private overiding tmoran
@ 2000-05-04  0:00 ` Robert A Duff
  0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 2000-05-04  0:00 UTC (permalink / raw)


tmoran@bix.com writes:

> One compiler refuses to compile this code, giving the indicated
> error message.  Other compilers accept it just fine and print
> "in test1" then "in test2".  Who's right?

I don't see anything illegal in this program.
But I could be missing something.

- Bob

> -----------------
> package test1 is
>   type Root is tagged null record;
>   procedure P(X : in out Root);
> end test1;
> 
> with ada.text_io;
> package body test1 is
>   procedure P(X : in out Root) is
>   begin
>     ada.text_io.put_line("in test1");
>   end P;
> end test1;
> 
> with test1;
> package test2 is
>   type Branch is new test1.Root with private;
> private
>   type Branch is new test1.Root with null record;
>   procedure P(X : in out Branch);
> end test2;
> 
> with ada.text_io;
> package body test2 is
>   procedure P(X : in out Branch) is
>   begin
>     ada.text_io.put_line("in test2");
>   end P;
> end test2;
> 
> with test1, test2;
> package test3 is
>   type A is new test1.Root with null record;
>   type B is new test2.Branch with null record;
> end test3;
> 
> with test3;
> procedure test is
>   X : test3.A;
>   Y : test3.B;
> begin
>   test3.P(X);
>   test3.P(Y);   -- One compiler says "expected type A, found type B"
>                 -- others have no complaints
> end test;




^ permalink raw reply	[flat|nested] 2+ messages in thread

* inheritance and private overiding
@ 2000-05-04  0:00 tmoran
  2000-05-04  0:00 ` Robert A Duff
  0 siblings, 1 reply; 2+ messages in thread
From: tmoran @ 2000-05-04  0:00 UTC (permalink / raw)


One compiler refuses to compile this code, giving the indicated
error message.  Other compilers accept it just fine and print
"in test1" then "in test2".  Who's right?
-----------------
package test1 is
  type Root is tagged null record;
  procedure P(X : in out Root);
end test1;

with ada.text_io;
package body test1 is
  procedure P(X : in out Root) is
  begin
    ada.text_io.put_line("in test1");
  end P;
end test1;

with test1;
package test2 is
  type Branch is new test1.Root with private;
private
  type Branch is new test1.Root with null record;
  procedure P(X : in out Branch);
end test2;

with ada.text_io;
package body test2 is
  procedure P(X : in out Branch) is
  begin
    ada.text_io.put_line("in test2");
  end P;
end test2;

with test1, test2;
package test3 is
  type A is new test1.Root with null record;
  type B is new test2.Branch with null record;
end test3;

with test3;
procedure test is
  X : test3.A;
  Y : test3.B;
begin
  test3.P(X);
  test3.P(Y);   -- One compiler says "expected type A, found type B"
                -- others have no complaints
end test;




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-05-04  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-04  0:00 inheritance and private overiding tmoran
2000-05-04  0:00 ` Robert A Duff

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