From: gwtmp01@... Date: 2007-02-06T08:20:49+09:00 Subject: Re: Proc vs lambda vs proc On Feb 5, 2007, at 4:28 PM, Brian Candler wrote: > Now, I wonder why you couldn't approach this problem from the other > direction: instead of having two or more different types of lambda, > which > handle 'return' semantics differently, have a single type of lambda > and two > different return statements. For example: > > return val # return from enclosing method > result val # return from this block only I think Ruby already has this via 'break'. Also, the default behavior of returning the last expression evaluated in a block is an implicit 'break' in Proc.new procs. Sometimes you want a Proc to behave like the body of a method (the lambda flavor of procs) and sometimes you want it to behave like the body of an iterator (the Proc.new flavor of procs). > That is, use the same argument list handling for a 'def' method > definition, > a block, and a Proc/proc/lambda. That seems to be a goal of the 1.9/2.0 line of Ruby as part of 'cleaning up' the semantics of block argument scope. I wish there was some better terminology for the two different types of procs (rather than 'lambda type' and 'Proc.new type'). I think Pickaxe uses 'raw proc' but I can never remember which type of proc is being referenced by that phrase. Gary Wright