From: ahoward Date: 2003-01-31T11:44:38+09:00 Subject: Re: Local variables & blocks On Fri, 31 Jan 2003 nobu.nokada@softhome.net wrote: > Hi, > > At Fri, 31 Jan 2003 09:44:28 +0900, > ahoward wrote: > > under the new rules if i : > > > > module M > > CLOSURE = lambda { x = 42 } > # defined?(x) > > end > > > > include M > > > > would 'x' be defined here or not? > > I guess it's not defined. In Ruby, as far as I understand, > local variables always belong to their scope, and modules do > enclose it. The only difference here should be whether x is > accessible or not after CLOSURE inside the module. right. you're question answered mine. i keep forgetting modules have their own scope. i *think* what matz is saying is that it would be defined under 'new rules' (though it is not now) since the closure still refereces it. perhaps proc blocks should be a special case? others? i had a tough enough time grasping the whole closure/scope thing in perl and with namespaces in the mix it's even tougher... the hard part is remembering that all the other things which introduce scopes will remain, even if blocks no longer do... to all involved in this thread so far i must say here that i have appreciated all the commentary and learned/remembered a fair bit. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================