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,start X-Google-Attributes: gid103376,public From: Rusnak Subject: Destructor question Date: 1998/12/02 Message-ID: <3665B85D.A2663591@nowhere.com>#1/1 X-Deja-AN: 417999171 Content-Transfer-Encoding: 7bit Organization: Lockheed Martin Missiles and Space Company, Sunnyvale, Ca. Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-12-02T00:00:00+00:00 List-Id: 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