Discussion:
Can we assign to value parameters in Oberon/Oberon-07?
(too old to reply)
nojb
2010-08-15 15:48:00 UTC
Permalink
Hello,

Is this legal in Oberon-07?

MODULE M;
PROCEDURE F(A : INTEGER);
BEGIN
A:=123
END F;

BEGIN
F(123)
END M.

Thanks!
N
Chris Burrows
2010-08-16 00:18:27 UTC
Permalink
Post by nojb
Is this legal in Oberon-07?
MODULE M;
PROCEDURE F(A : INTEGER);
BEGIN
A:=123
END F;
BEGIN
F(123)
END M.
Yes - that is legal in Oberon-07. The behaviour is the same as in Oberon and
Oberon-2.

However, a new feature in Oberon-07 allows you to protect against
modification of parameters by using the CONST keyword. e.g.

MODULE M;

VAR
v: INTEGER;

PROCEDURE P(CONST a : INTEGER);
BEGIN
a := 999 (* Compile-time error: Read-only *)
END P;

BEGIN
v := 123;
P(v)
END M.

Regards,
Chris Burrows

CFB Software
Astrobe: ARM Oberon-07 Development System
http://www.astrobe.com

Loading...