comp.lang.ada
 help / color / mirror / Atom feed
* Change in behavior of & operator between 83 and 9x?
@ 1994-10-05 16:04 Paul Graham
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Graham @ 1994-10-05 16:04 UTC (permalink / 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."



^ permalink raw reply	[flat|nested] 2+ messages in thread
[parent not found: <19941006.090935.490@vnet.ibm.com>]

end of thread, other threads:[~1994-10-13  1:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-10-05 16:04 Change in behavior of & operator between 83 and 9x? Paul Graham
     [not found] <19941006.090935.490@vnet.ibm.com>
1994-10-13  1:43 ` Keith Thompson @pulsar

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