comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Destructor question
Date: 1998/12/06
Date: 1998-12-06T00:00:00+00:00	[thread overview]
Message-ID: <m3ww455vx7.fsf@mheaney.ni.net> (raw)
In-Reply-To: 3666F7F1.9B107D38@nowhere.com

I give an example of how to implement a dispatching constructor in my
Nov 1998 post (with the subject "No subject", unfortunately) to the ACM
patterns archive.

<http://www.acm.org/archives/patterns.html>

The post itself is titled Yet Another Visitor, and shows how to
implement a tagged type with a private operation ("method") that
dispatches on the tag of the item, and frees the storage associated with
that object.

The type Composite_Equipment is very much like your container type: it's
a container that contains class-wide objects.

If you have trouble locating the post in the archive, send me your real
email address and I'll send it to you.

Matt



Rusnak <bogus@nowhere.com> writes:

> Now to the more important question:  I assume that IF I am going to use the
> Ada.Finalization package, that all my tagged records should be based off of
> the Controlled type within that package.  I would may also have to override
> the Finalize procedure since a derived class could allocate memorey for new
> attributes of the tagged record.  The Finalize, Initialize, and Ajust
> procedures do NOT take an access type however.  What I  have is an array of
> access values to a "'Class" type, and I need to deallocate the memory
> associated with each of the access values.  One cannot write an
> Unchecked_Deallocation for a "'Class" object (this makes sense).  What I
> need is to write is a dispaching procedure (i.e. a mehotd of a class) like
> the following:
> 
>     Given a type Instance which is an abstract tagged record and a type
> Object which is of type access all Instance and a type Class_Object which
> is of type access all Instance'Class,
> I would like to define a procedure:
> 
>     procedure Deallocate(The_Object : in out Object) is abstract;
> 
> which is dispatching.  The compiler certainly lets me declare such a
> procedure, but I can never use it, since it cannot accept a  parameter of
> type Class_Object to get it to dispatch.  Another solution is possible, but
> the above solution (if "implementable") would be the cleanest  and least
> intriusive way to go.
> 
> On another note,  if i override a proceudre in a derived class, how can I
> "chain" it to its super class (i.e.,  call  within the procedure the super
> class procedure which it overrides)?  I could certainly see the use in
> chaining  the Initialize procedure of the Controlled class mentioned
> above.  Explicit casting doesn't seem to work, and casting is not a very
> desirable solution anyway.
> 
> -John




  parent reply	other threads:[~1998-12-06  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-02  0:00 Destructor question Rusnak
1998-12-03  0:00 ` Jeff Carter
1998-12-03  0:00   ` Rusnak
1998-12-04  0:00     ` Robert I. Eachus
1998-12-06  0:00       ` Matthew Heaney
1998-12-08  0:00         ` Robert I. Eachus
1998-12-06  0:00     ` Matthew Heaney [this message]
1998-12-07  0:00     ` Jeff Carter
1998-12-06  0:00 ` david.c.hoos.sr
1998-12-06  0:00   ` Matthew Heaney
1998-12-08  0:00   ` Robert I. Eachus
1998-12-06  0:00 ` Matthew Heaney
replies disabled

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