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,start X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: "Inefficiency" of controlled types Date: 1997/06/29 Message-ID: #1/1 X-Deja-AN: 253501472 Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-06-29T00:00:00+00:00 List-Id: 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 (818) 985-1271