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,6c424a2d310d290 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Ada Generic Library (very) preliminary release Date: 1997/07/13 Message-ID: #1/1 X-Deja-AN: 256580743 References: <33C39534.E8DAC63D@elca-matrix.ch> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-07-13T00:00:00+00:00 List-Id: In article , Brian Rogoff 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 (818) 985-1271