comp.lang.ada
 help / color / mirror / Atom feed
From: Nige <nigel.scott@uk.thalesgroup.com>
Subject: Re: Using controlled types to trace program execution
Date: Thu, 07 Mar 2002 08:56:05 +0000
Date: 2002-03-07T08:54:18+00:00	[thread overview]
Message-ID: <3C872B25.937014FD@uk.thalesgroup.com> (raw)
In-Reply-To: u8cck9q2rqrvbc@corp.supernews.com

Matthew Heaney wrote:
> 
> "Nige" <nigel.scott@uk.thalesgroup.com> 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.



  reply	other threads:[~2002-03-07  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-26 13:39 Using controlled types to trace program execution Nige
2002-02-26 18:26 ` tmoran
2002-02-27 11:44   ` Nige
2002-03-06 15:20 ` Matthew Heaney
2002-03-07  8:56   ` Nige [this message]
2002-03-07 16:43     ` Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
2002-02-27 11:55 Christoph Grein
2002-02-27 17:59 ` Jeffrey Carter
2002-02-28 15:24   ` Nige
replies disabled

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