3 ms·
unnamed classes with an () operator They do have a name, but unfortunately it's just a compiler-generated one that's not known beforehand. And you would think
by userbinator 12y ago
unnamed classes with an () operator
They do have a name, but unfortunately it's just a compiler-generated one that's not known beforehand. And you would think that because the body of the lambda is really inside an operator(), 'this' could naturally be used to refer to the lambda itself, but alas, it doesn't work:
http://stackoverflow.com/questions/14531993/can-lambda-functions-be-recursive http://stackoverflow.com/questions/14531993/can-lambda-funct...
This is one thing about lambdas that I think the standards folks messed up. Having a lambda call itself might not be such a compelling use case, but it comes from the more general fact that a lambda cannot refer to itself, even though there isn't any reason preventing it from doing so; e.g. being able to pass itself ('this') as a parameter to some other function can be very useful.
- mjevans 12y agoYou're asking for a persistent first class function; write it like one.