3 ms·
i haven't used ruby excessively, but one example i found just by looking at it a bit is that blocks are redundant with lambdas to me it seems the language is t
by tokipin 18y ago
i haven't used ruby excessively, but one example i found just by looking at it a bit is that blocks are redundant with lambdas
to me it seems the language is trying to promote higher-level programming by making what is perhaps a common usage of first-class functions more explicit. but i can't say this is necessarily the best choice
another thing is lambdas are poorly-implemented, requiring the .call thing (perhaps due to the parens-less function calls.) this matters to me because i use a lot of first-class function stuff
for personal coding i use Lua, which to me feels more powerful than Ruby (from the perspective of abstractive power,) yet is much more streamlined
- raganwald 18y agoblocks 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.