2008/10/13 Phlip <phlip2005 / gmail.com>:

> An important goal of encapsulation is to give everything the narrowest scope
> possible. Without closure, if we need 'a' to have a lifespan as long as
> 'bar', we have to make 'a' into a data member. That widens 'a's scope.
>
> With closures, 'a' has the narrowest scope possible over a long lifespan.
> That is a major win - and it's why platforms without closures don't know
> what they are missing!

I agree that it's a powerful means but I'm not as enthusiastic as you
are. After all in OO languages you can easily emulate a closure by
creating a class with appropriate methods and data members.  Closures
can on the other hand make code harder to comprehend because the
interaction between the closure and the local variable is not obvious.

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end