Scoping: blocks allow binding and changing globals without declaring it so #7234
Closed
Description
opened on Jun 12, 2014
In repl when I do this:
foo = 1
bar() = (foo=foo+1)
bar()
I get ERROR: foo not defined
. So far so good.
But if I write it like this:
begin
foo = 1
bar() = (foo=foo+1)
bar()
end
I get 2.
Wrapping it in block changes the behavior. Apparently the bar() inside a block can access foo without declaring it global. And outside the block, I can see foo, so foo is really a global.
Activity