From: David Alan Black Date: 2004-04-17T17:44:10+09:00 Subject: Re: New Local Variable Scope rule Hi -- ts writes: > >>>>> "D" == David Alan Black writes: > > D> ts writes: > > D> I admit I'm confused by this. Is 'local' being introduced? And if > D> |a| is a block variable, isn't it local to the block anyway? > > [ruby-talk:63199] > > >> and what do you do with this ? > >> > >> Thread.new { a = 1 } # like Proc or like lambda ? > >> NewClass.new { a = 1 } # like Proc or like lambda ? > >> new_method { a = 1 } # like Proc or like lambda ? > > D> I'm not sure what you mean. Do you mean what would I do if I were > D> designing Ruby 2.0, > > yes, > > D> or what do I think Matz will have them do? I > D> don't know, since I still don't know the answer to the above (whether > D> Proc and lambda will be different in this respect). I think maybe you > D> think that I know, but I don't :-) > > If you introduce a difference between Proc and lambda, what do you do > with the examples that I've given ? > > Thread will work like Proc or like lambda ? Every code block will work (I assume!) like every other code block. (Otherwise learning how to use blocks would be like learning irregular verbs.) So if Thread.new takes a block, that's exactly the same as any other method taking a block. But that may or may not mean that Proc objects and lambdas, neither of which (as I understand it) are the same thing strictly speaking as code blocks (the thing that would be called a Block if there were a Block class :-) behave the same as each other. Going back to the original point (more or less): I'm just a little perplexed by the whole idea of closures (blocks, Procs, lambdas) having this compile-time effect on local variables in their context of creation. David -- David A. Black dblack@wobblini.net