Re: Trouble with overriding and class-wide parameters



On Sat, 15 Jul 2006 20:20:58 +0200, Yves Bailly wrote:

Dmitry A. Kazakov wrote:
What are you trying to achieve? The code looks wrong to me. Why are you
using access types in a procedure? Why do you want to overload two
different Setup? If the second parameter has to be covariant then Ada does
support it:

It's only a very reduced sample code, extracted from a much larger
code base. The particular needs for access types are specific to
this code base. That said, replace any "not null access" for the
first parameters with "in out" and you'll get the same effect. The
second parameter *has* to be an access type, as it can be null
on purpose. See it as "parent object", in a tree-like structure
(just to give an idea).

In that case yet another version of Setup without the second parameter
would be a better choice. Pointers aren't much Ada way.

Anyway that does no explain the motives, so it is difficult to say how to
solve it in an Ada way. As for workarounds and kludges, you can use a fully
qualified name the Setup you want to call to:

Sub_Pkg.Setup (st'Access, ...);

I understand all of this might seem a little bit odd, now I really
would like to understand what happens and why it's not the second
Setup() (from Sub_Pkg) which is called.

See the post by Jeffrey Carter. It is probably a compiler bug, because the
program looks illegal.

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