title: “EXCEPTION::FUNC_CALL Function” date: 2025-09-11 author: “laplante@plcb.ca” version: “1.0.1”
exception::func_call — return an array of the current function call stack
The exception::func_call
function returns an array containing the current function call stack.
It is useful for debugging or introspection, allowing developers to trace the active call hierarchy.
res={{
func g(i) {
"g"; i; " "; func_call(); "\n";
}
func f(i) {
"i"; i; " ";
func_call(); "\n";
if i > 2 {
g(i);
}
if i > 0 {
f(i-1);
}
"end"; i; " "; func_call(); "\n";
}
f(3);
"Last: "; func_call();
}}.
Return
res=i3 ["f"]
g3 ["f","g"]
i2 ["f","f"]
i1 ["f","f","f"]
i0 ["f","f","f","f"]
end0 ["f","f","f","f"]
end1 ["f","f","f"]
end2 ["f","f"]
end3 ["f"]
Last: [].
res={{
func g(i) {
"g"; i; " "; func_call(); "\n";
x := func_call();
l := length(x)-1;
"current "; x[l]; "\n";
}
func f(i) {
"i"; i; " ";
func_call(); "\n";
g(i);
x := func_call();
"current "; x[length(x)-1]; "\n";
}
f(5);
"Last: "; func_call();
}}.
return
res=i5 ["f"]
g5 ["f","g"]
current g
current f
Last: [].