comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: "Inefficiency" of controlled types
Date: 1997/06/29
Date: 1997-06-29T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680002906971508070001@news.ni.net> (raw)


I'm curious about early in a derivation tree controlled types should be
introduced, given that there is some overhead in their use.

For example, suppose I have a stack type

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;

In this formulation, Controlled is introduced at the root of the tree. 
This makes it very convenient for derived types, because they can just plug
in their own version of Finalize, and no component wrappers are necessary.

However, we really only need this for unbounded forms, which use heap
allocation.  For bounded forms (implemented as an array), finalization is
not really required, and so there is an "unnecessary" amount of overhead.

We don't have to introduce Controlled that early in the hierarchy.  Clients
that need it could declare a Controlled wrapper for that stack component
that requires finalization (say, a list component used to implement the
unbouned stack).

My question for the language designers is, Which is the preferred
technique?  Introduction of Controlled at the root, or locally at a branch? 
Does introduction at the root add "too much" inefficiency, or are
"unnecessary" calls optimized away?

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-29  0:00 Matthew Heaney [this message]
1997-06-30  0:00 ` "Inefficiency" of controlled types Simon Wright
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