Define the function in basic calculator bc as
define void f () { test=42; print "all done\n"; }
I'd have thought the value of test would be limited to the scope of the function f, but no, test equals 42 globally. Is there no way to limit the scope of variables in bc functions? I.e. is there are way to define local variables in bc?
You need to specify an
AUTO_LISTin your function definition. From the bc manual,So to keep the
testvariable "local" in your function, you'd use