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,e5a45a5d0fd8cbee X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: Question: inheritance from non-tagged types. Date: 1998/08/12 Message-ID: #1/1 X-Deja-AN: 380369215 References: <35D16EB9.195B3686@tech.swh.lv> Mail-Copies-To: sam@ada.eu.org Content-Type: text/plain; charset=US-ASCII Organization: TELECOM Paris Mime-Version: 1.0 (generated by tm-edit 7.108) Newsgroups: comp.lang.ada Date: 1998-08-12T00:00:00+00:00 List-Id: >>>>> "Maxim" == Maxim Senin writes: Maxim> - is it correct to derive tagged type from non-tagged type like Maxim> here I derive Object from Controlled? It is not correct to derive a tagged type from a non-tagged type. However, Ada.Finalization.Controlled *is* a tagged type, so your question does not apply here, and your derivation is correct. Maxim> - I derive Object from Controlled to allow garbage collection Maxim> for all Objects and their derivatives. Is it correct? Will it Maxim> work? I know garbage collection is not implemented in most Maxim> ADA compilers, but it's defined by language standard. I Maxim> believe that if I write program for "standard ADA compiler" Maxim> this code is correct. Is it true? Having a type deriving from Controlled does not trigger any magic garbage collection, it only lets you define Initialize, Adjust and Finalize primitives that will be called respectively at initialization time, copy time and finalization time. If an Ada[1] compiler uses a garbage collector, you don't need to use a controlled object to trigger it, those are orthogonal issues. However, if you want to write portable code, it is safer to use instanciations of Ada.Unchecked_Deallocation to ensure that you will reclaim unused storage[2]. Sam Footnotes: [1] Yes, Ada, not ADA [2] Even if you have no guarantee that storage will get reclaimed in fact :) -- Samuel Tardieu -- sam@ada.eu.org