Re:I don’t like the Ruby 1.9 hash syntax
by chc on Tuesday December 13, 2011 @10:07PM
(#3350394)
Clojure's Lisp roots make its minimalistic hashes possible. There is a possible reason for separators in a language that doesn't have special syntax for function application (e.g. function calls can be written as "foo bar" rather than "(foo bar)" or "foo(bar)"), but Ruby doesn't take advantage of it. Take this map:
Without the punctuation, it would be very ambiguous:
[ Parent
| on HN ]
Re:I don’t like the Ruby 1.9 hash syntax
by jcromartie on Wednesday December 14, 2011 @10:03PM
(#3354854)
I don't know about Ruby 1.9, but in 1.8, you can't do (for example):
{ :foo => rand 40 }
It requires parens. So Ruby seems to enforce some limit where it's too ambiguous.
Re:I don’t like the Ruby 1.9 hash syntax
by rayiner on Wednesday December 14, 2011 @04:49AM
(#3351262)
I cringe at the thought of whitespace as an infix operator...
That's not really the right way to look at it. Function application is just the default interpretation of two juxtaposed symbols. It's not any worse than "new MyObject()", which has whitespace acting just as much like an infix operator. There's no inherent reason why you'd need a special operator to apply "capitalize" but not "-" or "new" or "def". That's just how C does it, and by an accident of history most mainstream languages just parrot C by default.