comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Aliasing or referencing assignment
Date: Sat, 10 Sep 2005 13:28:16 +0200
Date: 2005-09-10T13:28:16+02:00	[thread overview]
Message-ID: <87slwdp3fz.fsf@ludovic-brenta.org> (raw)
In-Reply-To: m3irx9yzxo.fsf@rr.trudgett

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.  The complexity of this is probably
just above what can be preelaborated automatically.

You can have preelaborated unbounded strings if they are constant and
you declare them in a package which is preelaborated, e.g.

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

(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.).

-- 
Ludovic Brenta.



  reply	other threads:[~2005-09-10 11:28 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 [this message]
2005-09-11 20:43           ` David Trudgett
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