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-Thread: 103376,c0d4e990924eb044 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!feeder1.news.saunalahti.fi!nntp.inet.fi!inet.fi!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Fri, 13 Mar 2009 20:46:35 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Newbie question -- dereferencing access References: <72516b38-1711-4588-b53b-7b42773f70c2@w34g2000yqm.googlegroups.com> <1IednThMP8E8sCfUnZ2dnUVZ8suWnZ2d@posted.plusnet> <71ut2oFn4m2pU1@mid.individual.net> <49BA8A57.7090200@tgrowe.plus.net> <49ba8f44$0$31873$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <49baa9f6$0$14898$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: 81.17.205.61 X-Trace: 1236969975 news.tdc.fi 14898 81.17.205.61:33186 X-Complaints-To: abuse@tdcnet.fi Xref: g2news2.google.com comp.lang.ada:5087 Date: 2009-03-13T20:46:35+02:00 List-Id: 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 . @ .