On 9/25/06, Brian Mitchell <binary42 / gmail.com> wrote: > On 9/25/06, Rick DeNatale <rick.denatale / gmail.com> wrote: >> I think that the proper documentation of > > Kernel#raise/Thread#raise should be that it causes a non-local return > > unless it is rescued, in which case the value is the value of the > > expression in the rescue. That's how it works now. > > Well, those words are sort of confusing: > > begin > @x = raise > rescue > 42 > end > > p @x #=> nil > > @x = raise rescue 42 > > p @x #=> 42 No it's the same thing. The value of the lvalue in this case is the value of raise, which since the raise was rescued is 42. I think that my proposed documentation covers this case. > To put the result into better perspective, the binding of = is to the > entire expression including the rescue, which has the result of 42 > [1]. Except in this case the only 'entire expression' which includes the rescue is: begin; x=raise;rescue; 42;end And x is not being assigned the value of this expression. >This makes much more sense as one could imagine an invisble > wrapper like: > > @x = begin raise rescue 42 end But I think it makes even more sense to explain the syntax as it is rather than modifying it. > So should raise w/o the rescue be illegal? (no begin/end semantically) Too fussy, I think. > > Of course the final arbiter is Matz. > > Agreed. I personally think that this is a rather unimportant corner > case. I'm not sure I would change anything myself. > > Brian. > > [1] Note that: > > x = begin > raise > resue > 42 > end > > p x #=> 42 Again this is the same case in slightly different clothing. The value of the begin expression is that of the last statement, which is the raise expression, ... -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/