General discussions about working with the Astrobe IDE and programming ARM Cortex-M3, M4 and M7 microcontrollers.
- Posts: 60
- Joined: Tue Feb 12, 2019 2:59 am
Code: Select all
P = POINTER TO R;
R = RECORD END;
PROCEDURE P1(r: R);
PROCEDURE P2(VAR r: R);
PROCEDURE P3(p: P);
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).
- Site Admin
- Posts: 422
- Joined: Fri Dec 31, 2010 12:30 pm
The call to P3 is the most efficient (just). The calls to P1 and P2 generate identical code for the reason you state.