comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Null Range in Unconstrasined Array
Date: Tue, 8 Sep 2009 10:54:08 -0700 (PDT)
Date: 2009-09-08T10:54:08-07:00	[thread overview]
Message-ID: <68f49a20-2142-46ee-bed8-e5b3cad398e0@l35g2000pra.googlegroups.com> (raw)
In-Reply-To: wcck50cckjx.fsf@shell01.TheWorld.com

On Sep 6, 5:41 am, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
> There are several ways to implement that.
> For example, the procedure could be passed the bounds as separate
> parameters, in two registers.  I don't consider that to
> be "memory allocated for My_Array", because it is not
> allocated when the compiler sees My_Array -- it is allocated
> when the compiler sees a call (and separately for each call).
> In this case, My_Array'Address = X'Address is likely.

To elaborate on this a bit further: Suppose you define a record type
for reading a file with Ada.Direct_IO, that looks something like this:

  type Employee_Data is record
      Name     : String (1 .. 50);
      Address1 : String (1 .. 40);
      Address2 : String (1 .. 40);
      City     : String (1 .. 30);
      State    : String (1 .. 2);
      ...
  end record;

(Reminds me of my COBOL programming days...)  Anyway, it would be very
unexpected for the compiler to put two extra integers in the record
for each of these strings, and it would mess up your file I/O.  But
you have to have the ability to pass any of those fields to a
subprogram with a parameter type "String", and the bounds have to be
passed to the subprogram somehow.  I think it's most likely that the
bounds will be passed separately, as Bob suggested, either by passing
them in separate registers, creating a three-word temporary structure
that contains the bounds and a pointer to the data and passing the
address of that structure (with that structure disappearing after the
subprogram returns), creating a two-word structure with the bounds and
passing the address of that in a register, etc.  Something along those
lines.  But I'd actually be surprised if *any* implementation
allocated extra space in an Employee_Data record to hold the bounds of
each field.

                                             -- Adam



  reply	other threads:[~2009-09-08 17:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01  1:28 Null Range in Unconstrasined Array Rick
2009-09-01  3:11 ` Randy Brukardt
2009-09-01 14:50 ` Adam Beneschan
2009-09-01 15:34   ` Robert A Duff
2009-09-06 12:11     ` Peter C. Chapin
2009-09-06 12:41       ` Robert A Duff
2009-09-08 17:54         ` Adam Beneschan [this message]
2009-09-09  8:35           ` Stephen Leake
2009-09-09 13:00             ` Robert A Duff
2009-09-09 19:22             ` sjw
2009-09-10 23:24               ` Stephen Leake
replies disabled

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