comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: "Inefficiency" of controlled types
Date: 1997/06/30
Date: 1997-06-30T00:00:00+00:00	[thread overview]
Message-ID: <x7vhgefswdv.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: mheaney-ya023680002906971508070001@news.ni.net


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




  reply	other threads:[~1997-06-30  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-29  0:00 "Inefficiency" of controlled types Matthew Heaney
1997-06-30  0:00 ` Simon Wright [this message]
1997-07-02  0:00   ` Tucker Taft
1997-06-30  0:00 ` David S. Gibson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox