comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Ada Generic Library (very) preliminary release
Date: 1997/07/13
Date: 1997-07-13T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001307970142410001@news.ni.net> (raw)
In-Reply-To: Pine.SGI.3.95.970709082112.10832B-100000@shellx.best.com


In article <Pine.SGI.3.95.970709082112.10832B-100000@shellx.best.com>,
Brian Rogoff <bpr@shellx.best.com> wrote:


>> - Many components are just plain record types, where I think good Ada 95
style
>> would make them tagged types for several reasons: automatic finalization and
>> possibility of inheritance among others.
>
>Deliberate choice. STL uses no dynamic dispatch, and strives for the
>efficiency of "hand coded C". While it may not be there, automatic
>finalization of components won't help the Ada version. 

There may be confusion here: in Ada 95, there is no dynamic dispatch unless
it's on a class-wide object.  There is only a small space-penalty, to store
the tag.

Be very careful about using the STL - written in C++, using all the idioms
of that language - as a model for an Ada 95 component library.

Given this:

   type Root_Stack is abstract tagged private;

   type Bounded_Stack is new Root_Stack with private;
...
   The_Stack : Bounded_Stack;
begin
   Push (5, On => The_Stack);

This is as time-efficient as "hand coded Ada 83."  (Or C, for that matter.) 
The operation Push is statically bound, even though the type itself is
tagged.

It would be true, however, that if Root_Stack derived (either publicly or
privately) from Finalization.Controlled, then there would be a small
penalty to call Initialize, Finalize, and Adjust, a penalty that need not
be incured by bounded forms (ie, implemented as an array).

To get maximum efficiency (and to not give those programmers with
"optimitis" the excuse not to use the library), the library designer might
very well decide to not inherit from controlled at the root, and to
implement an unbounded form (say) by extending the uncontrolled parent with
a component that is controlled.  This localizes the "inefficiency" of
controlled type usage to only those branches where it is strictly required.

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




  reply	other threads:[~1997-07-13  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-08  0:00 Ada Generic Library (very) preliminary release Brian Rogoff
1997-07-09  0:00 ` Richard Kenner
1997-07-09  0:00   ` Brian Rogoff
1997-07-09  0:00   ` Robert Dewar
1997-07-09  0:00 ` Mats Weber
1997-07-09  0:00   ` Brian Rogoff
1997-07-13  0:00     ` Matthew Heaney [this message]
1997-07-13  0:00       ` Brian Rogoff
1997-07-13  0:00         ` Matthew Heaney
1997-07-13  0:00           ` Brian Rogoff
1997-07-14  0:00             ` Jon S Anthony
1997-07-14  0:00               ` Brian Rogoff
1997-07-14  0:00         ` Jon S Anthony
replies disabled

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