General discussions about working with the Astrobe IDE and programming ARM Cortex-M0, M3, M4 and M7 microcontrollers.
-
gray
- Posts: 143
- Joined: Tue Feb 12, 2019 2:59 am
- Location: Mauritius
Post
by gray » Mon Apr 15, 2019 2:47 am
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).
-
cfbsoftware
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
-
Contact:
Post
by cfbsoftware » Mon Apr 15, 2019 11:43 am
The call to P3 is the most efficient (just). The calls to P1 and P2 generate identical code for the reason you state.