On May 26, 2008, at 11:01 AM, Yukihiro Matsumoto wrote:
>
> You should read
>
> twotimes = -> x {2 * x}
>
> as "twotimes is 2 times x where x is not yet
assigned", here -> works
> as incomplete left to right assignment operator. So,
I think we're all comfortable with the concept--it's just
the notation.
The juxtaposition of = and -> just doesn't sit well with
most of us.
twotimes = x { 2 * x }
reads better to me, as does
twotimes = fn x -> { 2 * x }
as does
twotimes = λ x -> { 2 * x }
and
twotimes = lambda {|x| 2 * x }
In fact, given a change that allows block arguments to be
like method
arguments, then maybe no other change is needed. We can
always alias
lambda to something shorter, and then everyone is happy
n_times = λ { |n=2| λ {|val| n*val}}
twotimes = n_times[2]
twotimes[3]
Dave
|