Re: Newbie question -- dereferencing access



Tim Rowe wrote:
Tim Rowe wrote:

Georg Bauhaus wrote:

Tim Rowe schrieb:

Alex R. Mosteo wrote:


But I can't put an unconstrained type into a record.


Have you seen Bounded_String (and Unbounded_String)?


Not yet, but I'll go and explore...



Ok, I've seen it now! Am I correct that the statement in the
spec that "No storage associated with an Unbounded_String object
shall be lost upon assignment or scope exit" means somebody else
has done all the work of handling the underlying access types
and I don't need to worry?

That is the intent, yes, as Pascal Obry already replied.

I note that it does have a free method, but presumably that's just for early release before it goes out of scope.

There could be such a method for Unbounded_String, but actually the Free procedure in Ada.Strings.Unbounded works on the type String_Access, which is just an access to an ordinary fixed-length String (assumed to be dynamically allocated if Free is used).

I have often used Unbounded_String but never that procedure Free or the String_Access type. They have no public connection to Unbounded_String; probably they are declared in Ada.Strings.Unbounded just because the private implementations of Unbounded_String commonly use them, and the language designers thought that they might as well be public in case somebody finds them useful for other purposes.

If I wanted to discard the storage of an Unbounded_String variable S at some point in the program, before S goes out of scope, I would assign S := Null_Unbounded_String. This is likely to discard the storage for S, but I think the Ada standard does not guarantee that it happens at the assignment; it might happen later.

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
.



Relevant Pages

  • Re: Newbie question -- dereferencing access
    ... some point in the program, before S goes out of scope, I would assign S:= Null_Unbounded_String. ... This is likely to discard the storage for S, but I think the Ada standard does not guarantee that it happens at the assignment; ... doing hard real time, but then if I don't know a maximum length for a string I couldn't show compliance with hard real time constraints anyway, could I? ...
    (comp.lang.ada)
  • Re: Oscilloscope for SMPS design?
    ... A storage model is a big plus when working on ... suffcient.Storage circuitry is more complexity to fail,and the ... My 7633 scope is nearly 40 years old and still going strong so its not ... One cool thing about the digitals is that you can freeeze an ...
    (sci.electronics.design)
  • Re: Advice on a new Exchange 2003, dual-site installation please.
    ... I'd seriously push to change the scope now. ... Do an interim migration to 2003 ... storage and a clustered back-end using SAN ... I'd prefer to put the bridgehead on the front-end to ...
    (microsoft.public.exchange.admin)
  • Re: Storage Oscilloscope Tek 434 (was Re: Repair broken Tek 485 or buy good used 2465/A/B?)
    ... What is a "Storage Oscilloscope"? ... Usually a 'storage' scope will allow you to save a trace that is one ... Most scope general purpose probes are compatible. ...
    (sci.electronics.repair)
  • Re: String pointers and string arrays
    ... scope of where you are declaring it. ... Storage is not in any scope. ... When initializing a pointer like: ...
    (comp.lang.c)