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,2f1406ca802cdec5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!news.linkpendium.com!news.linkpendium.com!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Aliasing or referencing assignment From: David Trudgett Organization: Very little? References: <87slwdp3fz.fsf@ludovic-brenta.org> Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:VGEDfaS6LWdTV3rIerLgOhNyFw0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 12 Sep 2005 06:43:50 +1000 NNTP-Posting-Host: 61.8.42.109 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1126471703 61.8.42.109 (Mon, 12 Sep 2005 06:48:23 EST) NNTP-Posting-Date: Mon, 12 Sep 2005 06:48:23 EST Xref: g2news1.google.com comp.lang.ada:4577 Date: 2005-09-12T06:43:50+10:00 List-Id: Ludovic Brenta writes: > David Trudgett writes: >> Without knowing the details of how they work, I was just assuming >> they would be pre-elaborated during the compilation process. > > Internally, they may be implemented by an array and a used length. > When the used length grows beyond the length of the array, the array > is reallocated to grow in size. I suppose that's the general idea I had in the back of my mind. > The complexity of this is probably just above what can be > preelaborated automatically. It might be tricky, but I'm no compiler writer, so I'll keep my mouth shut! ;-) > > You can have preelaborated unbounded strings if they are constant and > you declare them in a package which is preelaborated, e.g. That's useful to know. Thank you. > > with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; > package Constants is > pragma Preelaborate; -- or better yet, Pure > > function "+" (R : in String) return Unbounded_String > renames To_Unbounded_String; > > S : constant Unbounded_String := +"Some fixed string"; > end Constants; > > HTH Yes, it is helpful, thanks. I also like the way you've renamed To_Unbounded_String to a right associative "+". Very interesting indeed. Another person posted a code snippet showing a long package name being renamed to something shorter. It seems 'rename' has more uses than I at first thought... :-) > > (The above package can be declared Pure. In addition to being > preelaborated, Pure packages promise that they have no side effects: > no visible global variables, no access parameters, and no use of > System.Address.). I'll keep it in mind the next time I have need of some purity! ;-) Thanks again for your comments. David -- David Trudgett http://www.zeta.org.au/~wpower/ "That a careful reader looking for a fact can sometimes find it with diligence and a skeptical eye tells us nothing about whether that fact received the attention and context it deserved, whether it was intelligible to the reader or effectively distorted or suppressed. What level of attention it deserved may be debatable, but there is no merit to the pretense that because certain facts may be found in the media by a diligent and skeptical researcher, the absence of radical bias and de facto suppression is thereby demonstrated." -- Herman and Chomsky, Manufacturing Consent, pp. xv.