From: AdaMagica on
I have a problem with an example in
http://en.wikibooks.org/wiki/Ada_Programming/Object_Orientation#Multiple_Inheritance

It proposes to use a mixin together with the Rosen trick, however for
unlimited types. This cannot work!

When such an object is assigned, the disciminant will inevitably point
to the wrong object.

For a detailed discussion of the problems involved, see my paper in
Ada Letters, Volume XIX, Number 4, December 1999, which you can also
find here:

http://www.christ-usch-grein.homepage.t-online.de/Ada/Finalization.html

Ada 2005 changed some of the rules; now mix-ins can have access
discriminants to nonlimited types, but the problem persists.

So how should the wikibook be corrected? Are there safe solutions to
the problem of mixins?
From: Ludovic Brenta on
On Jul 8, 11:34 am, AdaMagica <christoph.gr...(a)eurocopter.com> wrote:
> I have a problem with an example inhttp://en.wikibooks.org/wiki/Ada_Programming/Object_Orientation#Multi...
>
> It proposes to use a mixin together with the Rosen trick, however for
> unlimited types. This cannot work!
>
> When such an object is assigned, the disciminant will inevitably point
> to the wrong object.

I wrote a test case and confirm this; there is indeed a problem.

> For a detailed discussion of the problems involved, see my paper in
> Ada Letters, Volume XIX, Number 4, December 1999, which you can also
> find here:
>
> http://www.christ-usch-grein.homepage.t-online.de/Ada/Finalization.html

I'm not sure your solution works in all cases because it uses only one
"slot" per task, per tagged type, to store the access value to the
enclosing object. My gut feeling is that this makes assumptions as to
the ordering of calls to Adjust and Finalize that may not be always
correct in the presence of multiple objects of the same type.

> Ada 2005 changed some of the rules; now mix-ins can have access
> discriminants to nonlimited types, but the problem persists.
>
> So how should the wikibook be corrected? Are there safe solutions to
> the problem of mixins?

Right, I'm curious. I re-read sections on controlled types and mixin
inheritance in John Barnes' book but he leaves this entire problem as
an exercise to the reader (specifically, exercise 19.3). This seems
too complicated for a beginner.

--
Ludovic Brenta.
From: Simon Wright on
Ludovic Brenta <ludovic(a)ludovic-brenta.org> writes:

> Right, I'm curious. I re-read sections on controlled types and mixin
> inheritance in John Barnes' book but he leaves this entire problem as
> an exercise to the reader (specifically, exercise 19.3). This seems
> too complicated for a beginner.

I've checked the answers, John was solving a simpler problem (to keep
track of how many instances of a type have been created, and to give
each a unique ID). Although he says that "[having] a component of a
controlled type [...] will give the effect of controlling objects of
[the containing type]" this won't result in the ability to fully support
initialize/adjust/finalize.
From: AdaMagica on
On 8 Jul., 18:07, Ludovic Brenta <ludo...(a)ludovic-brenta.org> wrote:
> On Jul 8, 11:34 am, AdaMagica <christoph.gr...(a)eurocopter.com> wrote:
>
> I wrote a test case and confirm this; there is indeed a problem.
>
> > For a detailed discussion of the problems involved, see my paper in
> > Ada Letters, Volume XIX, Number 4, December 1999, which you can also
> > find here:
>
> >http://www.christ-usch-grein.homepage.t-online.de/Ada/Finalization.html
>
> I'm not sure your solution works in all cases because it uses only one
> "slot" per task, per tagged type, to store the access value to the
> enclosing object. My gut feeling is that this makes assumptions as to
> the ordering of calls to Adjust and Finalize that may not be always
> correct in the presence of multiple objects of the same type.

But this is the essence of the paper - it *can only work for limited
types* just because of all this. There is no such solution with mixins
for non-limited!
 | 
Pages: 1
Prev: OpenGL in Ada
Next: N best things about Ada?