On Tue, 2016-04-12 at 12:21, Didier Verna <did...@didierverna.net> wrote: > Mauro <mauro...@runbox.com> wrote: > >> On Tue, 2016-04-12 at 11:10, Didier Verna <did...@didierverna.net> wrote: >>> Hello, >>> >>> I'm wondering if anyone has ever seen an actual use for dynamically >>> creating a new global variable by using the "global" keyword from >>> within a local scope? >> >> https://github.com/JuliaLang/julia/blob/6b5a05eb1a029aef93f77b60bb1d745c7d6e1d8d/base/managers.jl#L175 > > Thanks, but :-). Two comments (related): > > 1. in that particular case, you're doing it not really because you want > to dynamically define your global function, but because you need the > lexical closure (your let is at the top-level). How about > non-functional variables?
If I understand correctly, you argue that all global bindings should be declared in the (lexical) global scope. An inner scope could then use that binding by using `global`. But new global bindings could not be created in local scopes. I think that would functionally be equivalent to the current status. I have no feeling about which would be superior syntactically. > 2. also, technically, your lexical closure isn't required for the > function itself, but for the particular method you're defining. But I > guess there's no way of declaring an empty generic function? function foo end