------art_4809_23849085.1208484000099
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 4/17/08, Marc Heiler <shevegen / linuxmail.org> wrote:
>
> > lambda are perfect anytime you want a context sensitive result and
> > don't want to code everything in one massive global scope.
>
>
> My problem with lambda's is that I have a hard time to find a
> real use case for them. I am not sure of some use case with
> lambda {} that brings a definite advantage over i.e. just
> using some special object or simple method.


Short answer: they are more more concise and convenient.

Ever use C++ STL?  In this library a "functor" is a very important concept
(for various comparators, visiting objects, etc).  You make a functor by
defining a class with a primary method for functor's functionality
("operator()").  It might also have some state (possibly maintained through
other methods) or references to things external to the functor.

In ruby, this type of thing is done with blocks and lambdas.  But, it is a
lot more concise and convenient.  Because blocks/lambdas have access to
variables in the scope where they are defined (which can also be used to
create state), there shouldn't be a need to create dedicated "functor"
classes.

I code in C++ everyday and miss the not having closures.  From what I've
read, C++ will get closures (like ruby has had since day 1) in the next
release (C++0x).

Eric

------art_4809_23849085.1208484000099--