[Oberon] Dynamic local array implementation
Diego Sardina
dsar at eml.cc
Sun Oct 15 19:33:52 CEST 2017
On Sun, Oct 15, 2017, at 06:19 PM, Andreas Pirklbauer wrote:
>
> I presume Swift “inout” it is close to what you mean by OUT.
>
Uhm... I don't know Swift, but I see inout more like a by value-result
strategy while an out parameter is a by result strategy.
There is also a nice exercise in Wirth's compiler book (page 81) that
asks to replace the VAR parameter concept by the notion of an OUT
parameter. It says that it's the inverse of the value parameter.
However, taking the current semantic of Oberon-07 (all structured
parameters are by reference) we can simulate these strategy modes in
this way:
TYPE Person = RECORD ... END;
(* By value *)
PROCEDURE Foo (p: Person);
VAR p1: Person;
BEGIN
p1 := p;
(* working on p1 ... *)
END Foo;
(* By value-result *)
PROCEDURE Foo (VAR p: Person);
VAR p1: Person;
BEGIN
p1 := p;
(* working on p1 ... *)
p := p1
END Foo;
(* By result *)
PROCEDURE Foo (VAR p: Person);
VAR p1: Person;
BEGIN
(* working on p1 ... *)
p := p1
END Foo;
By result is what I meant with an OUT parameter.
--
Diego Sardina
More information about the Oberon
mailing list