comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Equivalent of dynamic_cast (downcast) for tagged types
Date: Fri, 28 Jan 2011 15:13:08 +0100
Date: 2011-01-28T15:13:08+01:00	[thread overview]
Message-ID: <joz7ejpgeda0$.etbrqjysvoke$.dlg@40tude.net> (raw)
In-Reply-To: c235da0b-6fd9-494a-9681-d962bcb4a9dd@u24g2000prn.googlegroups.com

On Fri, 28 Jan 2011 05:11:16 -0800 (PST), AdaMagica wrote:

> On 28 Jan., 10:16, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>> On Thu, 27 Jan 2011 14:35:28 -0800 (PST), Maciej Sobczak wrote:
>>> I have submitted this bug report more than one year ago. Looks like
>>> nobody even bothered to check it.
>>
>> Well, I am not a language lawyer to tell if the behavior (public overriding
>> of a private primitive operation) is legal.
>>
>>> The bug submission states that Adjust is wrongly recognized as
>>> overriding, which it shouldn't be - but now I have hit something more
>>> interesting.
>>
>> It must be overriding because Adjust is a primitive operation. Whether the
>> compiler should allow it to become publicly declared as an overriding is
>> another question.
> 
> The public specification of Ada.Finalization.Limited_Controlled has no
> Adjust operation, so there is no primitive operation with that name
> which you can override, full stop.

It has no *visible* primitive operation.

> It's irrelevant if there is some
> internal one deeply burrowed in the compiler's implementation.

Unfortunately it leaks out. Consider this:

package P is
   type T is tagged private;
private
   type T is tagged null record;
   procedure Foo (X : in out T);
end P;

with P;
package Q is
   type S is new P.T with null record;
   procedure Foo (X : in out S);
end Q;

with Q;
package P.R is
   type U is new Q.S with null record;
   procedure Bar (Object : in out U'Class);
end P.R;

package body P.R is
   procedure Bar (Object : in out U'Class) is
   begin
      Foo (Object); -- Which Foo is called here? Is there one or two?
   end Bar;
end P.R;

This problem can also be observed with components. E.g. P.T may have a
component Baz, declared privately. Q.S may have "another" Baz declared
publicly. P.R.U faces a name conflict which must be resolved in some of two
possible ways: "overloading" vs. "overriding."

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-01-28 14:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 15:46 Equivalent of dynamic_cast (downcast) for tagged types Maciej Sobczak
2011-01-27 16:18 ` Dmitry A. Kazakov
2011-01-27 17:10   ` J-P. Rosen
2011-01-27 17:35     ` Dmitry A. Kazakov
2011-01-27 22:49     ` Maciej Sobczak
2011-01-27 17:50   ` Georg Bauhaus
2011-01-27 22:35   ` Maciej Sobczak
2011-01-28  5:07     ` Yannick Duchêne (Hibou57)
2011-01-28  9:16     ` Dmitry A. Kazakov
2011-01-28 13:11       ` AdaMagica
2011-01-28 14:13         ` Dmitry A. Kazakov [this message]
2011-01-28 23:51           ` Randy Brukardt
2011-01-29  0:55             ` Adam Beneschan
2011-01-28 16:44       ` Adam Beneschan
2011-01-28 17:21         ` Dmitry A. Kazakov
2011-01-29  0:12           ` Randy Brukardt
2011-01-29  8:47             ` Dmitry A. Kazakov
2011-01-28 17:33         ` Adam Beneschan
2011-01-28 15:13     ` Maciej Sobczak
2011-01-28 17:47       ` Robert A Duff
2011-01-28 22:04         ` Maciej Sobczak
2011-01-30 20:22           ` Stephen Leake
2011-01-31  9:04             ` AdaCore, user community and communication channels Maciej Sobczak
2011-01-31 10:42               ` Georg Bauhaus
2011-01-27 19:33 ` Equivalent of dynamic_cast (downcast) for tagged types Adam Beneschan
replies disabled

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