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,9e5138de1ea5afeb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-07 00:54:21 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.esat.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!news!not-for-mail From: Nige Newsgroups: comp.lang.ada Subject: Re: Using controlled types to trace program execution Date: Thu, 07 Mar 2002 08:56:05 +0000 Organization: Thales Message-ID: <3C872B25.937014FD@uk.thalesgroup.com> References: <3C7B9007.FB5F257D@uk.thalesgroup.com> NNTP-Posting-Host: sswc014.int.rdel.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: rdel.co.uk 1015491258 12241 172.16.10.25 (7 Mar 2002 08:54:18 GMT) X-Complaints-To: postmaster@uk.thalesgroup.com NNTP-Posting-Date: 7 Mar 2002 08:54:18 GMT X-Mailer: Mozilla 4.77 [en] (X11; U; SunOS 5.6 sun4m) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:20893 Date: 2002-03-07T08:54:18+00:00 List-Id: Matthew Heaney wrote: > > "Nige" wrote in message > news:3C7B9007.FB5F257D@uk.thalesgroup.com... > > procedure Something is > > > > Here : Trace.Location ("Something"); > > > > begin > > null; > > end Something; > > Try this: > > with Ada.Finalization; > package Trace is > > type Location (S : access String) is limited private; > > private > > type Location (S : access String) is > new Ada.Finalization.Limited_Controlled with null record; > > procedure Initialize (L : in out Location); > procedure Finalize (L : in out Location); > > end Trace; > > with Trace; > procedure Op is > S : aliased String := "Op"; > Here : Trace.Location (S'Access); > begin > null; > end; > > You have to declare the string object as aliased. You don't need heap for > what you're trying to do. Thanks - that does solve my original problem, but what I was ultimately after was a single declaration to keep it as simple as possible, the idea being that as subprograms are created, a single line can be cut and pasted into each one. What I've got working now allows me to just do: procedure Something is package Unit is new Trace; begin null; end Something; Cheers, Nige.