Maybe I'm confused about what you mean by "using globals". I assumed you mean just accessing a global in any way from a function. So, for example, this would be using a global:
module M foo = 1 bar() = foo end But this has no side effects since the global isn't modified. Are you talking about assigning to a global from inside a function? If so, doesn't that *require* the global declaration? Or are you talking about mutating the content of a global – which doesn't change it's binding. E.g. something like this: module N a = [1] b(x::Int) = push!(a,x) end On Wed, Jun 11, 2014 at 8:28 AM, Tony Fong <[email protected]> wrote: > Yes, I thought I was catching the right error, but later realized that I > was being too militant assuming that a proper function has no "closure". > Obviously there is, and the default closure has all the globals. > > However, I think using globals in a function can be surprising for a user > that assumes no side effect, so I could "downgrade" the lint message level > from ERROR to FYI. What do you think? > > Tony > > > On Tuesday, June 10, 2014 10:22:42 AM UTC-4, Stefan Karpinski wrote: > >> This is really nice work. In the future, I'd really like to move bits of >> TypeCheck and this sort of linting into base Julia, maybe invoked with a -w >> flag. >> >> Regarding this: >> >> Using globals in function without declaring them (This one isn't an >>> error, but I personally prefer explicit declaration of globals dependency >>> inside functions for readability.) >> >> >> I'm not sure how you're dealing with this, but this would, as stated, >> warn every time you call a function the way I'm reading it. Are you >> specifically not warning for globals that are used as call heads? I >> certainly wouldn't want to have to declare as global every function I'm >> going to use. >> >> >> On Tue, Jun 10, 2014 at 7:18 AM, Tony Fong <[email protected]> wrote: >> >>> It's a great idea! I'll look into it. Thanks for the pointer. >>> >>> >>> On Tuesday, June 10, 2014 5:50:27 AM UTC-4, René Donner wrote: >>>> >>>> I don't know how feasible it is, but a (perhaps optional) inclusion of >>>> the functionality in https://github.com/astrieanna/TypeCheck.jl would >>>> be great! >>>> >>>> >>>> >>
