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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,927ae253da8bb547 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-01 08:33:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Specialization Date: 01 Jun 2002 11:30:03 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <4519e058.0205300909.5bfb317d@posting.google.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1022945849 4131 128.183.220.71 (1 Jun 2002 15:37:28 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 1 Jun 2002 15:37:28 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:25152 Date: 2002-06-01T15:37:28+00:00 List-Id: Simon Wright writes: > Stephen Leake writes: > > > One more: require the client to pass in a Finalize procedure: > > > > generic > > type Element is private; > > with procedure Finalize (Item : in out Element) is <>; > > package Foo is > > type Element_array is array (1 .. 10) of Element; > > > > procedure Empty (Item : in out Element_Array); > > > > end Foo; > > > > Now Empty can call Finalize on each element of the array. For > > non-controlled types, Finalize can be a null operation. This is the > > approach I use in SAL; it allows a generic package to be > > instantiated with the widest range of types. > > I like this. > > The Element probably has to be visibly (to the client) controlled, for > her to get hold of the Finalize. Either that, or some "Free" operation is visible. In SAL, I actually call this parameter "Free_Item", not "Finalize". I was focussed more on the constrained/unconstrained and definite/indefinite issues, which determine whether the container elements are allocated or not, rather than on Controlled types. But the same mechanism works for both, which is why I use it. -- -- Stephe