From: Dave Cantrell Date: 2006-02-09T11:28:31+09:00 Subject: Re: What's the difference between copying and sharing in closure? David Vallner wrote: > I should also really make myself read long blocks of text to avoiding longer > blocks of text. > > Dňa Streda 08 Február 2006 05:57 Dave Cantrell napísal: >> In both the Ruby example and the pseudo-code case, >> the variable foo is a globally-scoped variable (well, for that code >> snippet anyway) and therefore should be accessible to any function that >> is subordinate to it. > > There's a new term, subordinate functions. But this is essentially the bit > where you blooped up, foo isn't globally scoped. Not even in that code > snippet. Method definitions aren't a closure on their enclosing lexical scope > - they run in a separate scope. Thanks for taking the time to explain that for me, David. Yeah, reading back over that I see it sounded kind of weird. I had made an assumption (I know, I know) that the function declared after the variable foo was running in the same or subordinate scope as the variable itself was declared --- whether global or not didn't seem to matter, but was convenient to write. So that is definitely where I tripped, because I'm used to dumb procedural languages (think VBScript and PL/SQL) that work more in that fashion. I've hacked Python enjoyably, but never fully delved into the deeper aspects of the language. Looks like I still have a lot to learn to fully understand Ruby. Luckily I came to the right place! :) -dave