Another possible solution to the global scope debacle

Late to the party here.

making everything outside of a function global, unless it is explicitly declared with local or let

Would variables inside the body of a let block be global? (Presumably, yes, see here.) If so, then IIUC this would nix being able to reliably copy/paste the body of a function into a let block (a common debugging strategy, whether performed manually or via Rebugger). For example, if I did this for a function which had a line first = true (defining a local variable named first), would I henceforth get the equivalent of

julia> first = true
true

julia> first([1,2,3])
ERROR: MethodError: objects of type Bool are not callable
Stacktrace:
 [1] top-level scope at none:0

?

In my own usage, simplifying 3-line REPL demos is not worth messing up systematic strategies; while I recognize the problem this issue is causing, for me personally this kind of change would be a step backwards.

However, being able to say local let ... end does seem like it would solve this problem. Can we keep that option on the table?

17 Likes