comp.lang.ada
 help / color / mirror / Atom feed
From: David Trudgett <wpower@zeta.org.au.nospamplease>
Subject: Re: Aliasing or referencing assignment
Date: Mon, 12 Sep 2005 06:43:50 +1000
Date: 2005-09-12T06:43:50+10:00	[thread overview]
Message-ID: <m3wtln49o9.fsf@rr.trudgett> (raw)
In-Reply-To: 87slwdp3fz.fsf@ludovic-brenta.org

Ludovic Brenta <ludovic@ludovic-brenta.org> writes:

> David Trudgett <wpower@zeta.org.au.nospamplease> 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.



  reply	other threads:[~2005-09-11 20:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-09  0:20 Aliasing or referencing assignment David Trudgett
2005-09-09  2:13 ` Steve
2005-09-09  7:33   ` David Trudgett
2005-09-09 15:40 ` Jeffrey Carter
2005-09-10  7:38   ` David Trudgett
2005-09-10 10:01     ` Martin Dowie
2005-09-10 10:33       ` David Trudgett
2005-09-10 11:28         ` Ludovic Brenta
2005-09-11 20:43           ` David Trudgett [this message]
2005-09-11  3:20         ` Jeffrey R. 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