[Oberon] Assignment to value parameters of pointer or procedure type

August Karlstrom fusionfile at gmail.com
Sun Feb 9 12:14:58 CET 2025


According to the Oberon-07 language reference from 2013-10-01 a scalar 
value parameter can be assigned to since it's just a local variable:

"A value parameter corresponds to an actual parameter that is an 
expression, and it stands for its value, which cannot be changed by 
assignment. However, if a value parameter is of a scalar type, it 
represents a local variable to which the value of the actual expression 
is initially assigned."

In the edition from 2015-03-18 "scalar type" was changed to "basic type":

"A value parameter corresponds to an actual parameter that is an 
expression, and it stands for its value, which cannot be changed by 
assignment. However, if a value parameter is of a basic type, it 
represents a local variable to which the value of the actual expression 
is initially assigned."

If I interpret this correctly a value parameters of pointer or procedure 
type cannot be assigned to. This procedure, for instance, is then invalid:

	PROCEDURE Length(t: List): INTEGER;
		VAR n: INTEGER;
	BEGIN
		n := 0;
		WHILE t # NIL DO
			INC(n);
			t := t.next
		END
	RETURN n
	END Length

Instead we need to introduce an extra local variable to step through the 
list:

	PROCEDURE Length(t: List): INTEGER;
		VAR n: INTEGER;
			p: List;
	BEGIN
		n := 0;
		p := t;
		WHILE p # NIL DO
			INC(n);
			p := p.next
		END
	RETURN n
	END Length

Does anyone know why "scalar type" was changed to "basic type". If my 
memory serves me correctly this has been discussed before but right now 
I cannot find the thread.


/August


More information about the Oberon mailing list