From: graham@clsi.COM (Paul Graham)
Subject: Change in behavior of & operator between 83 and 9x?
Date: 05 Oct 1994 16:04:49 GMT
Date: 1994-10-05T16:04:49+00:00 [thread overview]
Message-ID: <GRAHAM.94Oct5120449@canopus.clsi.COM> (raw)
If an array type A has component type B which is itself an array type, is it
possible to concatenate two arrays of type B to produce an array of type A?
For instance:
package foo is
type my_string is array(1 .. 3) of character;
type my_string_vector is array(positive range <>) of my_string;
c1 : my_string_vector := "abc" & "def";
end;
In this example, I want the value of the concanenation to be equivalent to
("abc", "def") -- my_string_vector(1 to 2)
But it can also be interpreted as
"abcdef" -- string(1 to 6), my_string(1 to 6), ???
which does not match the type of c1.
The 83 RM (4.5.3(4)) states "if both operands are one-dimensional arrays,
the result of the concatenation is a one-dimensional array whose length is
the sum of the lengths of the operands ...". Clearly the concatenation of
two strings is always a string, and never an array of strings.
But the 9x RM defines the result of a concatenation in terms of its result
type. In the above example the result type is known to be my_string_vector.
Thus the "&" should be "&"(x, y : my_string) return my_string_vector.
Is my understanding wrong, or is this an incompatibility between the 83 and
9x versions of Ada?
Paul
--
Paul Graham graham@compass-da.com Compass Design Automation, Inc.
(speaking only for myself) "Cekoslovakyalilastiramadiklarimizdanmissiniz."
next reply other threads:[~1994-10-05 16:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-10-05 16:04 Paul Graham [this message]
[not found] <19941006.090935.490@vnet.ibm.com>
1994-10-13 1:43 ` Change in behavior of & operator between 83 and 9x? Keith Thompson @pulsar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox