From: Tom Sawyer Date: 2003-02-14T16:20:23+09:00 Subject: Re: Lexical scope and closures On Thursday 13 February 2003 08:03 pm, Yukihiro Matsumoto wrote: > arr.each {|i| > local{|a,b| > c = .. > ... > } > } mmm...seems overly syntatical, might as well do: arr.each {|i;a,b| c = .. } though for some reason i don't like this either. feels like a aand b should be catching something, not just becoming local. > arr.each {|i| > let a = .. > let b = .. > c = .. > ... > } clean, though this is a declarative, which i thought you were trying to avoid. but maybe this is best. yet i think this would add complication: what would 'let' mean outside of block? wouldn't one be inclined to have it go further: class A def inititalize c = "instead of @c" let a = "instead of just a" end end which might be all well and good, but i think it's a little too late for this. so unless you really wanted to do this despite code breakage, 'let' and ':=' should probably be avoided --the inclination toward the above would be too strong. yet, something drives me to want procs and blocks to be like methods --that everything is local and you have to pass variables in and out, but this doesn't coincide well with current ruby, and perhaps defeats the purpose of closures. hmmm... might as well throw this out: arr.each do(a,b) |i| c = "is local" a = "not local" b = "not local" d = "is local" return d # but this gives d to outer scope end another idea to add to the pool. give it plenty of time, the best solution will clearly arise at some point. who knows, perhaps you got it right the first time: the way it is ;-) -- tom sawyer, aka transami transami@transami.net