comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Two simple language questions
Date: 1998/01/07
Date: 1998-01-07T00:00:00+00:00	[thread overview]
Message-ID: <dewar.884181720@merv> (raw)
In-Reply-To: 68uq34$7tk@tomquartz.niestu.com


Chip asks

<<First: It says in the Intro to Ada 9X, in Chapter 2, "General access types can
also be used to program static ragged arrays as for example a table of
messages of different lengths."  Now, I know this has been asked before, some
time ago, but I cannot seem to locate the text of the exchange.  What I want
to know is, exactly what is the syntax for doing this?  I've so far used
allocators, i.e.:

   strs:  StringArr :=
   (
       new string'("Line 1"),
       new string'("Line 2"),
       ...
       new string'("Line the Last")
   );

Which works great, but isn't exactly the "static" ragged arrays mentioned in
the intro.  What I want is something like "Line 1"'access, but of course that
doesn't work, nor have any of the sixteen-umpty variations that I've tried.
The RM just said that in X'access, X must be an aliased view of an object.
Well, hmph.  Hep me, hep me, please.
>>

I expect others will answer with the obvious use of 'Access on objects so
I won't repeat that here. I will note that you can find a nice example of
this use in the gnatcmd utility in the GNAT sources. In general I think
those who like learning from examples :-) may find it useful to browse the
GNAT sources for useful stuff. The stand alone utilities like gnatcmd are
quite accessible, as are many of the runtime library routines. Even the
main compiler code is reasonable to get into.

Second, the form with allocators, if used at the outer level in a library
package, does not seem particularly more or less static than the form with
the use of 'Access.

Here I am using static in an informal sense to mean no elaboration code at
runtime, which is not quite what static means in Ada, and is also, a bit
surprisingly, not quite what Preelaborate means.

A compiler might or might not generate code for the use quoted above of
allocators, it is certainly quite reasonable that it should not. 

A compiler might or might not generate code for the use of 'Access in an
aggregate, it is certainly quite reasonable that it should not.

So don't jump to conclusions too fast :-)





  parent reply	other threads:[~1998-01-07  0:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-07  0:00 Two simple language questions Chip Richards
1998-01-07  0:00 ` Matthew Heaney
1998-01-10  0:00   ` Two simple language questions (plural types) Michael F Brenner
1998-01-10  0:00     ` Robert Dewar
1998-01-10  0:00       ` Matthew Heaney
1998-01-10  0:00         ` Robert Dewar
1998-01-12  0:00         ` Anonymous
1998-01-12  0:00           ` Matthew Heaney
1998-01-12  0:00             ` Brian Rogoff
1998-01-13  0:00               ` Robert Dewar
1998-01-13  0:00                 ` Distinguishing type names from other identifiers Nick Roberts
1998-01-13  0:00                   ` Matthew Heaney
1998-01-14  0:00                     ` Stephen Leake
1998-01-24  0:00                       ` Matthew Heaney
1998-01-15  0:00                     ` Anonymous
1998-01-24  0:00                       ` Matthew Heaney
1998-01-24  0:00                         ` Martin M Dowie
1998-01-24  0:00                           ` Pred Nick Roberts
1998-01-25  0:00                           ` Distinguishing type names from other identifiers Matthew Heaney
1998-01-24  0:00                         ` Martin M Dowie
1998-01-15  0:00                   ` Aaro Koskinen
1998-01-17  0:00                     ` Martin M Dowie
1998-01-17  0:00                       ` Martin M Dowie
1998-01-25  0:00                       ` Matthew Heaney
1998-01-25  0:00                         ` Brian Rogoff
     [not found]                         ` <n5rs5FAStOz0Ew2+@dowie-cs.demon.co.uk>
1998-01-26  0:00                           ` Brian Rogoff
1998-01-27  0:00                             ` Martin M Dowie
1998-01-27  0:00                               ` Brian Rogoff
1998-01-27  0:00                                 ` Matthew Heaney
1998-01-28  0:00                                   ` Brian Rogoff
1998-01-28  0:00                                     ` Matthew Heaney
1998-01-29  0:00                                       ` Brian Rogoff
1998-01-30  0:00                                     ` Mats Weber
1998-01-28  0:00                                 ` Martin M Dowie
1998-01-12  0:00           ` Two simple language questions (plural types) Brian Rogoff
1998-01-11  0:00     ` Brian Rogoff
1998-01-07  0:00 ` Robert Dewar [this message]
1998-01-07  0:00 ` Two simple language questions Tucker Taft
1998-01-07  0:00 ` Dale Stanbrough
  -- strict thread matches above, loose matches on Subject: below --
1998-01-07  0:00 tmoran
1998-01-07  0:00 ` Matthew Heaney
replies disabled

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