A
Ara.T.Howard
Remember how the lambda method works: it takes a block parameter and
creates an object out of it. IMO this is very clean; blocks are the
basic building block and procs and bindings are built on top of them.
As to why we cannot remove the call to the lambda method, consider:
1. Ruby does have blocks, and
2. Ruby does not require parens for method calls.
If I write:
(1..10).map { |n| n ** 2 }
Should this be interpreted as:
(1..10).map(lambda { |n| n ** 2 })
or as:
(1..10).map do |n| n ** 2; end
If it were possible to merge blocks and proc objects without
introducting ambiguity and without losing backward compatibility, it
might not be a bad idea. I do not think this is possible, though.
Paul
perhaps a shorthand:
lambda{ puts 'lambda' } => Proc:0xb74041a0
&{ puts 'lambda too' } => Proc:0xb74041a1
i'm probably missing something, but i don't think the syntax '&{' occurs
anywhere now and '&' is already synomynous with blocks/procs/etc.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================