comp.lang.ada
 help / color / mirror / Atom feed
* Destructor question
@ 1998-12-02  0:00 Rusnak
  1998-12-03  0:00 ` Jeff Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Rusnak @ 1998-12-02  0:00 UTC (permalink / raw)


How are destrcutor methords properly implemented in Ada on tagged
records?  I have the following setup:

    Given a tagged record type:

       type Instance is abstract tagged
           record
              ...
          end record;

      type Object is access all Instance;

      type Class_Object is access all Instance'Class;

  and a package which keeps a container of "Class_Object"s.

   At the end of the day, I need to deallocate all the objects in the
container.
    The only way I could envision doing this is to write a Dispose
procedure which takes an access to an instance and dispatches to the
    approriate package (the one where the corresponding subclass of
Instance is actually defined) to do the deallocation.
    The Dispose procedure would dispose of the internals of the object
(if necessary) and then dispose of the object itself.  The procedure
    therefore needs to take an "in out Object" type:

    procedure Dispose(The_Object: in out Object) is abstract;

    I can't dispatch on this procedure, however, since it explicitly
takes an Object type and passing in a Class_Object type causes a
compilation
    error.  I can'e use an anonymous access type, since these are only
"in" parameters, and the access value of The_Object should be set to
null
    after deallocation.


Any suggestions are greatly appreciated.

My e-mail id is "jrusnak "on the domain "netgate.net".

Thanks
-John







^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1998-12-08  0:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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