2 ms·
> ass-backwards closures that's very surprising. I would say that C++ lambda expressions have been an incredible success and probably the best thing to come ou
by gpderetta 10y ago
> ass-backwards closures
that's very surprising. I would say that C++ lambda expressions have been an incredible success and probably the best thing to come out of C++11.
For example, rust started with boxed closures, because that's what all the 'proper' languages do. They were forced to switch to distinctly-typed, unboxed closures with similar capture modifiers to be competitive with C++ [1].
- steveklabnik 10y agoYour link got eaten, but we don't have capture modifiers anymore. Captures are inferred, and you can override this with a keyword to take all captures by value instead. This still lets you get the same effect as C++, but we find that it's generally less verbose. It depends though!
- gpderetta 10y ago> you can override this with a keyword to take all captures by value instead that's what I meant by modifiers :). It is not unlike [&] and [=] I guess (except for the "tiny" detail that lifetimes are checked). BTW, I'm not sure what the [1] reference in my comment was supposed to point to though.