comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ijs.co.nz>
Subject: Re: Unbounded Strings
Date: Fri, 10 Oct 2003 07:23:33 +1300
Date: 2003-10-10T07:23:33+13:00	[thread overview]
Message-ID: <nu5bovsoucltvmtg9ibsghq2086b7jf7na@4ax.com> (raw)
In-Reply-To: _XYgb.3237$dn6.2766@newsread4.news.pas.earthlink.net

On Wed, 08 Oct 2003 18:46:18 GMT, Jeffrey Carter <spam@spam.com> wrote:
>Andrew Carroll wrote:
>> I did some experimenting, thanks to Cohen's book and persistance I found
Is that book online?
...
>All elementary types are passed by copy, regardless of the parameter mode. 
>All tagged and limited types are passed by reference, regardless of the 
>parameter mode. For all other types, the compiler chooses the parameter 
>mode best suited to the type.

Other candidates for the by-reference type include:
 * records with an aliased field
 * records with a field that is a type that is either Volatile or Atomic.

Once tagged is used, then a type can't be renamed without having to
rename all of its procedures which is adverse to my idea of a language
that ought provide strong type checking. No procedures beneath/above this
line.

Use of the limited reserved word can stop the assigning of records which
can be too inconvenient.

This is what I do: use aliased fields, and if it results in a few extra
procedures, maybe they get inlined correctly:

   ---------
   type UST is Ada.Strings.Unbounded.Unbounded_String;

   type UST_Rec is tagged
      record
         Val   : aliased UST;
      end record;

   type UST_Ptr is access constant UST;

   function Access_To (X : UST_Rec) return UST_Ptr;
   ---------

By some method, the function returns a pointer to the field.

So the parameter is aliased and the term by-reference is not getting
properly explained when there is no consideration of what it means when
there is background garbage collecting.




Craig Carey




      parent reply	other threads:[~2003-10-09 18:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20031007175516.DC2884C40C8@lovelace.ada-france.org>
2003-10-08  5:52 ` Unbounded Strings Andrew Carroll
2003-10-08  6:22   ` Preben Randhol
2003-10-08 13:10   ` Marin David Condic
2003-10-08 13:19     ` Steve O'Neill
2003-10-08 18:46   ` Jeffrey Carter
2003-10-08 23:55     ` Mark Lorenzen
2003-10-09 18:23     ` Craig Carey [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox