From: Robert Klemme Date: 2003-01-29T21:45:34+09:00 Subject: Re: Local variables & blocks Hm, don't know. I can see the benefits but personally I prefer it the other way round: the calling scope stays in control. I am completely satisfied with max = 0 (IO.readlines (path)).each do |line| ... fields = line.split delim max = [max, fields].max ... end puts max >> 42 The difference is not too big and you achieve the same. Apart from that: from a technical point of view, what does happen if you create a Proc instance? Normally the variable binding is established at creation time. Your feature requires to bind a variable dynamically each time a block is used the first time in a certain context. I don't know whether this is feasible with the current interpreter implementation, but I do guess that it's a major change. Regards robert "ahoward" schrieb im Newsbeitrag news:Pine.LNX.4.33.0301290535530.2139-100000@eli.fsl.noaa.gov... > > > was on rubygarden and had this idea regarding local and blocks : > > in general, i like the way things work, but occansionally would like to be > able to 'export' a variable from inside a block. so, i think to myself, why > not an export keyword? something > > (IO.readlines (path)).each do |line| > export max = 0 > ... > fields = line.split delim > max = [max, fields].max > ... > end > > puts max >> 42 > > what'dya think? > > export would be a cross between C's static modifier (declared/defined once > only), but would be 'exported' into the parent scope - lexical or dynamic i'm > not sure - but you get the picture... > > the mnemonic is like that of the shell's 'export var=42' > > -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 > ==================================== >