









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










int plus (int a, int b) { return a + b; } … int x = plus(1,2); … Formal Parameters Actual Parameters Function Definition Function Call Function Body Observation: in function definitions formal parameters act as placeholders for the values of actual parameters. Chap 18
FUNCTION Divide(Dividend:Float, Divisor:Float) RETURN Float IS BEGIN RETURN Dividend/Divisor; END ... Foo = Divide(Divisor => 2.0, Dividend => 4.0); ... 2nd formal parameter becomes 2. 1st formal Parameter Becomes 4.
previous activation record return address a: 3 result:? current activation record previous activation record return address x: 3 b: 4 y: 4 z:? int plus(int a, int b) { a += b; return a; } void f() { int x = 3; int y = 4; int z = plus(x, y); }
Lvalues are values that have addresses, meaning they are variables or dereferenced references to a certain place.
void plus(int a, by-value-result int b) { b += a; } void f() { int x = 3; plus(4, x); }
previous activation record return address a: 4 current activation record previous activation record return address x: 3 b: 7
void plus(int a, by-value-result int b) { b += a; } void f() { int x = 3; plus(4, x); }
previous activation record return address a: 4 current activation record previous activation record return address x: 7 b: 7
void plus(int a, by-reference int b) { b += a; } void f() { int x = 3; plus(4, x); }
previous activation record return address a: 4 current activation record previous activation record return address x: 3 b:
void plus(int a, by-reference int b) { b += a; } void f() { int x = 3; plus(4, x); }
previous activation record return address a: 4 current activation record previous activation record return address x: 7 b: