From: "Aleksi Niemelä" Date: 2000-10-13T15:59:17+09:00 Subject: [ruby-talk:5498] Re: Some newbye question matz replies to Dave's example: > | a = 1 > | proc { |a| a = 99 } .call > | a # => 99 > (a) I don't like variable overriding, especially in declaration-less > language like Ruby. It seems, matz, that you valuate variable non-overridingness more than symmetry in parameter handling, if I understood correctly? So here's my current understanding what happens at above example: 1 var a is created 2 a is set to refer to the object 1 3 function proc is called with an associated block block won't be executed yet 4 variables in block's parameter list are created *if* they do not exists in outer binding, that means |a| is not created because it exists, as it was created at 2 5 a is set to refer to the object 99 6 the proc's returning Proc object's method 'call' is executed, which in turn executes the block passing no arguments to it Now I have a questions: why not bind the block's variables only at block's body? (not in the parameter list only) The reason why I'm asking this, even though you already answered to the question from one point of view, is that I believe there are several aspects here to consider - which you probably have already considered. Not binding at parameter list would be much clearer to me as the calling a method and a block wouldn't be that much different. For me, it's easiest to think in Ruby, when the differences between methods and blocks are as few as possible, the major difference being the binding. I think it's really weird to think one's passing a parameter when actually the parameter has been already bound. Thanks for enlightening comments. - Aleksi