From: ahoward Date: 2003-01-30T04:07:45+09:00 Subject: Re: Local variables & blocks On Thu, 30 Jan 2003, Joel VanderWerf wrote: > ahoward wrote: > > wouldn't that break backward compatibility since any code like > > > > x = 'something completely unrelated' > > .... > > # 1000 lines of code > > .... > > > > block_method do |arg| > > x = 42 > > end > > > > would clobber the previous x? > > That's how it works now, isn't it? whoa. to little sleep! apologies. that is, of course, how it works now. i guess i was wondering about automatically exporting every (currently local) block variable since code which did previously : loop do ... object = 42 ... end ... # code which may set object ... ... object and object.method ... may act differently since object would now _always_ be defined. it seems like the 'new' rule will cause people to start writing loop do object = 42 end object = nil to undef objects things. particularly with common var names like i, x, etc. personally i like loop do export object = 42 end because old code will work identically, the syntax is very clear, and it allows blocks to define variable outside their enclosing scope. -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 ====================================