Hi, below is a program in a statically-scoped language:
program main
int x, y;
void p1(value int y, void q(reference int)) {
void p2(reference int x) {
x := y + 2;
print(x);
q(y);
}
if x = y then q(y) else p1(y+1, p2)
}
void p2(reference int x) {
x := y + 2;
print(x);
}
x := 2;
y := x;
p1(0, p2);
end main
by "value" it means parameter transmitted by value, "reference" by reference.
Will function call "q(y)" in p2 cause infinite loop?