On Fri, Apr 29 2016, Yichao Yu wrote: > On Fri, Apr 29, 2016 at 8:33 AM, Tamas Papp <[email protected]> wrote: >> Default value expressions for optional and keywords arguments are >> evaluated in the scope of the module that defines the function, which >> seems to be the Right Thing to do, but I could not find this specified >> in the manual. Did I miss it or is it just not spelled out? Asking >> because I would submit a correction if it is the intended behavior. Eg > > This is just the default lexical scope. Note that it is *not* the > module that defines the function for closures. There's already a > section about the scope of default arguments so it is fine if you want > to submit something short that clarify this a little bit.
I wanted to submit a clarification but I don't understand your sentence "it is *not* the module that defines the function for closures." In the example below, I would reason about scope like this: (a different) bar is in the global scope for both modules, but the local scope of Foo.foo just takes it from Foo where it was defined (because of lexical scope). Is this reasoning correct? > >> >> --8<---------------cut here---------------start------------->8--- >> module Foo >> bar=1 >> foo(a=bar)=a >> end >> >> module Baz >> import Foo.foo >> bar=2 >> foo2()=foo() >> end >> >> Baz.foo2() # will then eval to 1 >> --8<---------------cut here---------------end--------------->8--- >> >> Best, >> >> Tamas
