3 ms·
Actually, I think defining new operators is impossible to do even this cleanly in Ruby. It's emphatically not well suited to this particular kind of metaprogram
by chc 16y ago
Actually, I think defining new operators is impossible to do even this cleanly in Ruby. It's emphatically not well suited to this particular kind of metaprogramming. You can override lots of operators and define methods that read kind of like language keywords, but AFAIK you can't define new infix operators without flat-out hacking the parser in C.
- draegtun 16y agoDefining infix operators in Perl6 is very straightforward. For eg: sub infix:<.oO>($name, $thought) { say "$name thinks $thought" } "szabgab" .oO "Perl 6 is cool"; ref: http://news.ycombinator.com/item?id=1607254 http://news.ycombinator.com/item?id=1607254