comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Delegating operations to parent (generic formal type)
Date: 06 Sep 2000 06:25:47 +0100
Date: 2000-09-06T06:25:47+01:00	[thread overview]
Message-ID: <x7vlmx63xd0.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: 39AC2C1B.FFA2E69C@averstar.com

Tucker Taft <stt@averstar.com> writes:

> The use of Initialize is legal.  This looks like an old-fashioned
> bug in APEX and ObjectAda 7.2.  The current AdaMagic front end has no
> problem "seeing" the Initialize operation.

Tucker,

Thanks very much. I'll pass on PRs ..

The following is a repost of my article "Visibility for operations of
formal private extensions" <x7v4s5af41m.fsf@pogner.demon.co.uk> which
seems to have similar difficulty. I'd be most grateful for any
comments ..

The code below gives compilation errors when compiling the view
conversion in P.Q.R.Proc's body, both in GNAT (3.13a1) and Apex
3.2.0b. They say that there's no visible interpretation: GNAT says

/home/simon/tmp/demo.ada:33:09: no candidate interpretations match the actuals:
/home/simon/tmp/demo.ada:33:15: expected type "New_T" defined at /home/simon/tmp/demo.ada:26
/home/simon/tmp/demo.ada:33:15: found private type "Base" defined at /home/simon/tmp/demo.ada:22
/home/simon/tmp/demo.ada:33:15:   ==> in call to "Proc" at /home/simon/tmp/demo.ada:27
/home/simon/tmp/demo.ada:33:15:   ==> in call to "Proc" at /home/simon/tmp/demo.ada:18(inherited)
/home/simon/tmp/demo.ada:33:15:   ==> in call to "Proc" at /home/simon/tmp/demo.ada:5

If I make P.Proc publicly visible, the compilation goes fine.

I believe we are somewhere near 12.5.1(21) here. My belief that it
should have compiled is based on the following:

* we know that P.Q.R.Base is a P.Q.Q_T

* a P.Q.Q_T (privately) inherits P.Proc

* P.Q.R's body has visiblity of the private part of P and therefore
  should be able to see that P.Q.Q_T inherits P.Proc

Note that P.Q.S's body _can_ see P.Proc.

I tried adding a private component to P.Q.Q_T, P.Q.R.Proc can see it
quite happily .. OK, the LRM reference above is about operations not
data, still!

==================================================================
package P is
    type T is tagged private;
private
    type T is tagged null record;
    procedure Proc (The_T : in out T);
end P;

package body P is
    procedure Proc (The_T : in out T) is
    begin
        null;
    end Proc;
end P;

package P.Q is
    type Q_T is new P.T with private;
private
    type Q_T is new T with null record;
end P.Q;

generic
    type Base is new Q_T with private;
package P.Q.R is
    type New_T is new Base with private;
private
    type New_T is new Base with null record;
    procedure Proc (The_T : in out New_T);
end P.Q.R;

package body P.Q.R is
    procedure Proc (The_T : in out New_T) is
    begin
        Proc (Base (The_T));
    end Proc;
end P.Q.R;

package P.Q.S is
    type S_T is new Q_T with private;
private
    type S_T is new Q_T with null record;
    procedure Proc (The_T : in out S_T);
end P.Q.S;

package body P.Q.S is
    procedure Proc (The_T : in out S_T) is
    begin
        Proc (Q_T (The_T));
    end Proc;
end P.Q.S;

with P.Q.R;
with P.Q.S;
package U is
    package U_P is new P.Q.R (Base => P.Q.S.S_T);
end U;



  reply	other threads:[~2000-09-06  5:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-13  0:00 Delegating operations to parent (generic formal type) Simon Wright
2000-07-13  0:00 ` tmoran
2000-07-14  0:00   ` Simon Wright
2000-07-14  0:00 ` Simon Wright
2000-07-15  0:00   ` Simon Wright
2000-08-28  0:00 ` Simon Wright
2000-08-29  0:00   ` Tucker Taft
2000-09-06  5:25     ` Simon Wright [this message]
2000-09-07 21:56       ` Tucker Taft
replies disabled

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