asteroid
asteroid copied to clipboard
implement 'nonlocal' keyword
The nonlocal command works analogous to the global command except that it will inspect the surrounding scopes rather than just the global scope. Example,
load system io.
function myfunc1 with none do
let x = "John".
function myfunc2 with none do
nonlocal x.
let x = "hello".
end
myfunc2().
return x.
end
io @println (myfunc1()).
should print out hello.
I am not quite sure we want this...this is only needed when writing nested function definitions where the nested function uses data from the surrounding function definition as non-local data. That is terrible programming and we should not support this kind of hacking.