Yukihiro Matsumoto wrote:
"need" is pretty relative indeed. And I'm a big fan of concise
notation in general. But still I don't think this is a good idea
(without special notation). Iterating method calls (like to_s in
above example), should be distinguishable from usual method calls,
because they are different, they act different, their implementations
are different.Besides that you need to have knowledge of whether #collect requires
mandatory block or not to tell how obj.collect.to_s works. Note that
#collect may or may not have mandatory block depends on its receiver.
Okay. Though we should consider that it can already be done, and
similar code is already being done in limited cases. Just as an example
here's how collect could be defined.
alias :old_collect, :collect
def collect( &yld )
if yld
old_collect( &yld )
else
Functor.new { |op, x| x.__send__(op) }
end
end
But even so, say a special notaion were the best option. What kind of
notations do we have left? Everything starts to seem so perlish. I
don't know. Maybe '->' could play a role here?
T.