* Re: Question: inheritance from non-tagged types.
[not found] <35D16EB9.195B3686@tech.swh.lv>
@ 1998-08-12 0:00 ` Samuel Tardieu
1998-08-12 0:00 ` Tom Moran
1 sibling, 0 replies; 2+ messages in thread
From: Samuel Tardieu @ 1998-08-12 0:00 UTC (permalink / raw)
>>>>> "Maxim" == Maxim Senin <maks@tech.swh.lv> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question: inheritance from non-tagged types.
[not found] <35D16EB9.195B3686@tech.swh.lv>
1998-08-12 0:00 ` Question: inheritance from non-tagged types Samuel Tardieu
@ 1998-08-12 0:00 ` Tom Moran
1 sibling, 0 replies; 2+ messages in thread
From: Tom Moran @ 1998-08-12 0:00 UTC (permalink / raw)
>type Object is abstract tagged private;
>private
> type Object is new ADA.Finalization.Controlled with null record;
Do you really want this abstract, or not abstract? It would help to
be consistent.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-08-12 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <35D16EB9.195B3686@tech.swh.lv>
1998-08-12 0:00 ` Question: inheritance from non-tagged types Samuel Tardieu
1998-08-12 0:00 ` Tom Moran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox