Re: ISO Open Array Parameters
- From: "Chris Burrows" <cfbsoftware@xxxxxxxxxxx>
- Date: Tue, 10 Apr 2007 23:29:51 +0930
"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
.
- References:
- ISO Open Array Parameters
- From: Tom Breeden
- ISO Open Array Parameters
- Prev by Date: ISO Open Array Parameters
- Next by Date: Re: ISO Open Array Parameters
- Previous by thread: ISO Open Array Parameters
- Next by thread: Re: ISO Open Array Parameters
- Index(es):
Relevant Pages
|