3 ms·
blocks are redundant with lambdas Except the semantics of the return keyword are corrupted if you get rid of blocks and procs while keeping lambdas. Makes me t
by raganwald 18y ago
blocks are redundant with lambdas
Except the semantics of the return keyword are corrupted if you get rid of blocks and procs while keeping lambdas. Makes me think return isn't worth the bother, but then again lots of people would hate a language without a return keyword.
- gunderson 18y agoI wouldn't say corrupted, just different. I imagine there are many cases in which the different semantics are used intentionally. This is really not a huge issue, b/c anyone who has worked with Ruby enough knows about it. It's mainly that the difference doesn't really make logical sense -- why would a "proc" behave differently from a "lambda"? Also note that: lamba { foo } means exactly the same as proc { foo } which is different than: Proc.new { foo } This sort of smells, but it wouldn't if there were a new keyword to represent the way Proc.new behaves... then everyone would flex their Ruby muscles by writing confusing hacks that utilized the behavior of StrongReturnProc.new ... :)
- raganwald 18y agoit wouldn't if there were a new keyword to represent the way Proc.new behaves My understanding is that there is a very good chance that Ruby 1.9 (when it stabilizes) will change the proc keyword to have Proc.new semantics instead of lambda semantics, for exactly the reason your give.