From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3dbb4bb0201c39eb X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Destructor question Date: 1998/12/06 Message-ID: #1/1 X-Deja-AN: 419250671 Sender: matt@mheaney.ni.net References: <3665B85D.A2663591@nowhere.com> <3666BACC.99E6BB06@spam.innocon.com> <3666F7F1.9B107D38@nowhere.com> NNTP-Posting-Date: Sun, 06 Dec 1998 03:52:25 PDT Newsgroups: comp.lang.ada Date: 1998-12-06T00:00:00+00:00 List-Id: 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. 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 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