Alternatively, what is the persistence of variables. Defining a variable as:
Code: Select all
// input and response
VAR i01 CHARACTER INIT ( "" );
Ok.
Code: Select all
// input and response
i01
ERROR: 'i01' has not been defined.
Code: Select all
// input and response
VAR i01 CHARACTER INIT ( "" );
Ok.
Code: Select all
// input and response
i01
ERROR: 'i01' has not been defined.
Code: Select all
operator p() returns integer;
begin;
var x init(2);
begin;
var y init(3);
end;
return x + y;
end;
end operator;
Code: Select all
VAR i01 CHARACTER INIT("");
WRITELN(i01);
Code: Select all
operator p() returns integer;
begin;
var x init(2);
begin;
var y init(3);
end;
return x + y;
end;
end operator;
Code: Select all
operator ping (p0, INT) returns integer;
begin;
var x INT;
x := p0;
IF x = 1 THEN return x ELSE x := ping (p0 -1);
end;
end operator;
Code: Select all
operator p(x int) returns int;
return if x > 0 then p(x - 1) else x end if;
end operator;
Code: Select all
var invocations init(0);
operator p(x int) returns int;
begin;
invocations := invocations + 1;
return if x > 0 then p(x - 1) else x end if;
end;
end operator;
Code: Select all
operator q(z int) returns int;
begin;
var invocations init(0);
operator p(x int) returns int;
begin;
invocations := invocations + 1;
return if x > 0 then p(x - 1) else x end if;
end;
end operator;
var result init(p(z));
writeln("Invocations: " || invocations);
return result;
end;
end operator;