comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Access to Unconstrained Arrays
Date: 1997/04/23
Date: 1997-04-23T00:00:00+00:00	[thread overview]
Message-ID: <dewar.861815616@merv> (raw)
In-Reply-To: E8znDv.72r@world.std.com



Bob Duff said

<<Note that the language designers never considered using fat pointers for
 access-to-array.  I continue to think that thin pointers are the better
 (simpler) solution overall.  So all of this reasoning assumes thin
 pointers.  Aside: with fat pointers, we could have allowed 'Access of
 slices under some circumstances.>>

Well of course it is true that thin pointers are simpler, but they are
also less efficient. In particular, they rule out the use of virtual
origins for arrays.

GNAT offers the programmer the choice of fat or thin pointers (to get thin
pointers, you use a size clause on the access type that restricts it to
address size).

However, since we do provide fat pointers, we can indeed allow 'Access
of slices under some circumstances. For example, the following program

   with Text_IO; use Text_IO;
   procedure a is
      type ax is access all String;
      q : String (1 .. 11) := "Hello World";
      p : ax;
   begin
      p := q (1 .. 5)'Unrestricted_Access;
      Put_Line (p.all);
   end a;

Of course this program is not portable (it is relying on the implementation
dependent attribute Unrestricted_Access). It is however reliably portable
to all GNAT implementations.

You cannot use 'Access itself this way of course, since that is not legal
Ada!





  reply	other threads:[~1997-04-23  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-16  0:00 Access to Unconstrained Arrays John Harbaugh
1997-04-18  0:00 ` John Harbaugh
1997-04-20  0:00   ` Robert Dewar
1997-04-21  0:00   ` Joel VanLaven
1997-04-21  0:00     ` Robert A Duff
1997-04-23  0:00       ` Robert Dewar [this message]
1997-04-18  0:00 ` Robert Dewar
1997-04-18  0:00 ` Joel VanLaven
1997-04-20  0:00   ` Robert Dewar
replies disabled

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