On Fri, 2006-11-10 at 19:46 -0800, Andrew Pinski wrote:
> On Fri, 2006-11-10 at 15:23 -0800, Sohail Somani wrote:
> > > Do you need new class types, or just an anonymous FUNCTION_DECL?
> >
> > Hi Mark, thanks for your reply.
> >
> > In general it would be a new class. If the lambda function looks like:
> >
> > void myfunc()
> > {
> >
> > int a;
> >
> > ...<>(int i1,int i2) extern (a) {a=i1+i2}...
> >
> > }
> >
> > That would be a new class with an int reference (initialized to a) and
> > operator()(int,int).
> >
> > Does that clarify?
>
> Can lambda functions like this escape myfunc? If not then using the
> nested function mechanism that is already in GCC seems like a good
> thing. In fact I think of lambda functions as nested functions.
Yes they can in fact. So the object can outlive the scope. A supposed
use is for callbacks. Personally, I'd use it to make stl more usable in
the cases where boost lambda doesn't help.
Thanks,
Sohail