From: jvl@ocsystems.com (Joel VanLaven)
Subject: Re: Access to Unconstrained Arrays
Date: 1997/04/18
Date: 1997-04-18T00:00:00+00:00 [thread overview]
Message-ID: <1997Apr18.141618.10240@ocsystems.com> (raw)
In-Reply-To: 335507B4.7A03@boeing.com
John Harbaugh (john.s.harbaugh2@boeing.com) wrote:
: When trying to pass pointers to objects of unconstrained array type, I
: am getting confusing compiler errors. For example:
: procedure Main is
: type Lists is array(Natural range <>) of Integer;
: type Lists_Ptrs is access all Lists;
: procedure Do_Something(To : in out Lists_Ptrs) is...
: List1 : Lists(1..4) := (1,2,3,4);
: List2 : Lists := (1,2,3,4);
: begin
: Do_Something(To => List1); -- Compilation Error. Why?
: Do_Something(To => List2); -- No problemo!!!
: end Main;
: List1 should be an anonymous constrained subtype of type Lists. I was
: under the impression that subtypes are simply a subset of their base
: type. Is this not the case for constrained subtypes of unconstrained
: types?
I think your compiler is stopping at the first error or something. Our
compiler says that both calls are incorrect. List1 and List2 are arrays,
NOT access values. So, neither call matches the procedure profile. In
fact, List2 IS constrained. It is given a constraint when it is
initialized. If your program were to assign (1,2) to either list it would
raise a constraint error (the same as for list1).
Did you try commenting out the first call? I hope that the compiler you
are using does not really accept the second call. If it does either it
is a bug in your compiler or in ours :). I am betting that neither has
a bug with respect to this.
To make this compile, you need to either change Do_Something or change
the two object declarations to be something like
List1 : Lists_Ptrs := new lists'(1,2,3,4);
List2 : Lists_Ptrs := new lists'(1,2,3,4);
: Thanks in advance for any who may respond.
: - John
No problem,
--
-- Joel VanLaven
next prev parent reply other threads:[~1997-04-18 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
1997-04-18 0:00 ` Joel VanLaven [this message]
1997-04-20 0:00 ` Robert Dewar
1997-04-18 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