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: Rusnak Subject: Re: Destructor question Date: 1998/12/03 Message-ID: <3666F7F1.9B107D38@nowhere.com>#1/1 X-Deja-AN: 418368337 Content-Transfer-Encoding: 7bit References: <3665B85D.A2663591@nowhere.com> <3666BACC.99E6BB06@spam.innocon.com> Content-Type: text/plain; charset=us-ascii Organization: Lockheed Martin Missiles and Space Company, Sunnyvale, Ca. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-12-03T00:00:00+00:00 List-Id: Jeff Carter wrote: > Rusnak wrote: > > > > How are destrcutor methords properly implemented in Ada on tagged > > records? I have the following setup: > > ... > > Assuming > > "destrcutor" should be "destructor" > > and > > "methords" should be "methods" > > then the answer to this question is that Ada does not have methods, much > less destructor methods. Ada has subprograms and entries. > > This is a MicroStuff Support answer: technically correct but useless. > Here's a useful answer: > > Your question seems to be about what Ada calls "finalization", which > refers to operations on objects of a type when the value of the object > becomes inaccessible (prior to assignment or when the object ceases to > exist). I refer you to the standard package Ada.Finalization for the > details of finalization in Ada (ARM 7.6). > > -- > Jeff Carter > E-mail: carter commercial-at innocon [period | full stop] com > "Perfidious English mouse-dropping hoarders." > Monty Python & the Holy Grail Sorry about the spelling mistakes on earlier post. The key terms "method" and "attribute" are object-oriented terms (which I believe are now accepted as part of UML but I can be wrong about that) and are not associated with any particular language. I would agree that Ada class objects do not have a "this" pointer, but tagged records do support dispatching operations which are essentially "methods" of the class. 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