2 ms·
I think you misunderstood the v0.x scoping algorithm. In v0.x, there were 3 scoping situations described in the documentation (function, toplevel, and outer). I
by manwe150 6y ago
I think you misunderstood the v0.x scoping algorithm. In v0.x, there were 3 scoping situations described in the documentation (function, toplevel, and outer). In v1.0, there was essentially 1 (plus clarifications on what a variable was "local" to in various, generally toplevel, situations). Now there are 2, but TOPLEVEL also emits the following warning, that you didn't mention, since it sees the behavior diverges between them:
Warning: Assignment to `l` in soft scope is ambiguous because a global variable by the same name exists: `l` will be treated as a new local. Disambiguate by using `local l` to suppress this warning or `global l` to assign to the existing global variable.
And while you write "same piece of code", the code you then paste is not the same: the statement "local" appears in a different statement block, leading to it being executed in a subsequent scope block.