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,e31963013a17b383 X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: "Inefficiency" of controlled types Date: 1997/06/30 Message-ID: #1/1 X-Deja-AN: 253917084 X-NNTP-Posting-Host: pogner.demon.co.uk [158.152.70.98] References: Organization: At Home Newsgroups: comp.lang.ada Date: 1997-06-30T00:00:00+00:00 List-Id: mheaney@ni.net (Matthew Heaney) writes: > with Ada.Finalization; > packages Stacks_G is > > type Root_Stack is abstract tagged private; > ... > private > > type Root_Stack is > new Ada.Finalization.Controlled with null record; > > end Stacks_G; This is a slightly different set of questions from Matthew's: What happens if I derive a type from Root_Stack and declare a primitive subprogram Finalize? Does it make a difference if the package in which I do the derivation is a child of Stacks_G? It seems intuitive to me that I need to expose the derivation from Controlled in the public part of Stacks_G if Finalize is to behave as expected; but there was that long thread recently about visibility of components and (as I recall) operations which might indicate differently (or even, in the case of child packages, that there was no point in my doing so!) Seems to me that if the type is controlled I should make it visibly so, so that users know that I need finalization and can arrange to call my Finalize (Initialize, Adjust) from theirs. The rule I've adopted is to say My_Type is new Ada.Finalization.Controlled with private; and then in the private part to derive from the type whose eventual root is Controlled. -- Simon Wright Work Email: simon.j.wright@gecm.com GEC-Marconi Radar & Defence Systems Voice: +44(0)1705-701778 Command & Information Systems Divsion FAX: +44(0)1705-701800