Re: ISO Open Array Parameters



"Tom Breeden" <tmb@xxxxxxxxxxxx> wrote in message
news:461B5214.1214.0092.0@xxxxxxxxxxxxxxx


I've just noticed that ISO M2 specifies that it is never allowed to assign
to an open array parameter as a whole
while within the called procedure.

eg,

PROCEDURE P(VAR a:ARRAY OF CHAR);
BEGIN

a := "a string";

END P;

is not allowed.

That seems a bit odd, considering a string literal can be assigned to any
other character array variable, no matter what the declared size.

It does not seem to pose implementation difficulties for the compiler,
since
the HIGH value is at a known place on the stack.

I must be overlooking the rationale? What was the thinking on this?


If that is so, one possible reason that I can think of is simply that the
string literal assignment is an exceptional case. Any other potential open
array assignment would not follow the normal rules for assignment
type-compatibility.

However, it would be a useful feature, and, you are right - if there are any
implementation difficulties they are not insurmountable

e.g. when Modula-2 evolved into Oberon / Oberon-2, the following became
possible:

PROCEDURE P(VAR a:ARRAY OF CHAR);
BEGIN
COPY("a string", a)
END P;

Then. later, when Oberon-2 evolved into Component Pascal, the following
became possible:

PROCEDURE P(VAR a:ARRAY OF CHAR);
BEGIN
a := "a string";
a := "a string" + " another string"
END P;

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp


.



Relevant Pages

  • Re: why one array continues to grow after repeated call
    ... It just so happens that the semantics of the = method on an Array ... But objects mutating is completely different to assignment. ... reference to some object), and store this reference in the local ... char *a; ...
    (comp.lang.ruby)
  • Re: chars
    ... definition doesn't say the object can't be an array. ... assignment; that value can include the value of a member that happens ... Well no. arr is a C array and arp is a pointer to char. ...
    (comp.lang.c)
  • Re: initialisation of a char pointer using char *s = "something"
    ... Remember m it a pointer. ... A string literal is an array of char. ... it's an assignment, not an initializer, and the object being ...
    (comp.lang.c)
  • Re: What my life is really like....
    ... > (like the using as array and assignment of array of char etc). ... > it initially only for variable strings and os interfacing? ...
    (comp.lang.pascal.delphi.misc)
  • Re: Window Management
    ... (* prompt is a string resource identifier specifying the string ... PROCEDURE YesNoCancel(prompt: ARRAY OF CHAR; ... VAR INOUT response: ARRAY OF CHAR): BOOLEAN; ...
    (comp.lang.ada)