2 ms·
Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features
by brlewis 19y ago
Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary. I do not think Ruby is better for having an additional syntax (block literals) that is just like an existing syntax (lambda) only more restricted.
- tptacek 19y agoThe syntax isn't meant to be "a better lambda". The syntax is meant to recast other language functions, like looping and iteration, in terms of messages and anonymous functions. Since idiomatic Ruby basically never has "for" loops, despite their easy availability in the language, I'm going to go ahead and call the "block" expiriment successful.
- brlewis 19y agoIf it's meant to recast certain language functionality in terms of anonymous functions, why didn't they just make block literals return anonymous functions? It still strikes me as an almost-could-have-been-great syntax. Idiomatic Scheme basically never has "do" loops, despite their being part of the core standard, and it's been that way for decades.
- tptacek 19y agoI agree that block syntax should semantically result in expression evaluating to a Proc object. This would be great: y = {|x| x} # => #<Proc> I agree that block syntax could therefore be greater than it is. I disagree that you can fairly knock Ruby for this, since blocks and implicit block arguments are still better than what you get in other languages.