comp.lang.ada
 help / color / mirror / Atom feed
From: Christoph Grein <christoph.grein@eurocopter.com>
Subject: Re: Using controlled types to trace program execution
Date: Wed, 27 Feb 2002 12:55:33 +0100 (MET)
Date: 2002-02-27T12:55:33+01:00	[thread overview]
Message-ID: <mailman.1014811022.406.comp.lang.ada@ada.eu.org> (raw)

Dynamic allocation and deallocation are not necessary:

generic

  Unit_Name: String;

package Trace is

private

  X: aliased String := Unit_Name;
  Follower: T (X'Access);

end Trace;

> tmoran@acm.org wrote:
> > 
>    A combination will do the job.
> >   You can't pass a string as a discriminant to your controlled type, and if
> > you pass an access-to-string type it will be a constant and you won't
> > be able to "free" the string.  But you can do it with two levels:
> >   type p is access string;
> >   type t(msg : access p) is new ada.finalization.limited_controlled with ...
> > Then use the generic instantiation as a shorthand for declaring an
> > aliased pointer to a new string'("something") followed by a declaration
> > of the controlled type with a 'access to that pointer as its parameter.
> 
> Thanks - I hadn't thought about declaring a package - only a variable.
> 
> Nige
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada



             reply	other threads:[~2002-02-27 11:55 UTC|newest]

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

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