Jesse Jones wrote:
> Yes, a beautiful example of the flexibility of Ruby. But I don't see
> how having both blocks and proc objects improves Ruby's expressiveness.

It doesn't.  You could drop the implicitly passed blocks and always deal 
with an explicit &block argument and not miss a bit of expressiveness 
There is a performance difference difference however, and I suspect that 
is the real reason why the yield syntax is supported (i.e. to avoid the 
overhead of reifying blocks into full fledged objects).  Perhaps a 
future optimization will make the &block syntax as efficient as the 
implicit yield syntax.  When that happens, the "block" concept can 
retreat to the interior of the interpretor (where it belongs) and not 
haunt developers with this weird "almost a proc, but not quite" 
semantics.  At least that's my view.

Actually what surprises me most about Ruby's one-block per method 
technique is how flexible it turns out to be.  One would think that 
having the ability to pass multiple blocks would be big improvement, but 
I suspect that the improvement in flexibility is merely incremental.

What surprises me about Ruby is the about of expressiveness you get, 
even though you are limited to only one block per method call.  You 
would think that having the ability to pass multiple closures to a 
method would be a big improvement,

 > Plenty of languages have blocks, but fewer languages could build
 > declarative structures as nicely as Joel was able to do. You also need
 > instance_eval and it helps a lot if the syntax is fairly free-form so
 > you can omit parenthesis in function calls.

All those help.  I've used both Lisp and Forth and really admire their 
ability to create tailored languages for a domain.  I think Ruby comes 
close to their level of flexibility, but does it with different tools 
that either Forth or  Lisp (i.e. macros and run-time code generation).

-- 
-- Jim Weirich    jim / weirichhouse.org     http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)