hierarchy destruction in Ada

Ada 95 provides a mechanism with tagged and type'class to allow dynamic dispatch. So if one has:

procedure something (O : basetype'class) is
enact (O);
end something;

then as we all know, with the appropriate redefinitions of enact () for the subtypes of basetype, we have dynamic dispatch.

But what about deallocation ? I want to declare:

type handle is access all basetype;

procedure dispose (ptr : in out handle);

and can't see how to make this deallocate the correct object. Obviously, one can dynamically dispatch on ptr.all but it seems impossible to solve the complete problem without an unchecked conversion. Anyone ?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

This is not the right forum for language specific questions

I suggest comp.lang.ada.

Take a look at the package Ada.Finalization.

FAQ update?

I felt old FAQ was pretty good at explaining policies. Cut&paste'ing several sentences to the new FAQ will probably be very cost-effective. I mean the red sentence, mostly.

Good idea