Code: Select all
MODULE M10;
TYPE
P = POINTER TO R;
R = RECORD END;
VAR
p: P;
r: R;
PROCEDURE P1(r: R);
END P1;
PROCEDURE P2(VAR r: R);
END P2;
PROCEDURE P3(p: P);
END P3;
BEGIN
P1(r);
P2(r);
P3(p)
END M10.
What are the differences in the overhead when calling the procedures? I would assume they are minimal, in particular for P2 and P3, but also for P1, as the value record parameter is read-only, hence no value copying needs to take place (in the original PiO of 1992, the authors recommend using VAR parameters if performance is important -- and it was the same for Modula-2, IIRC -- but I would assume that's the (or a) reason for the read-only rule in the current language version).