3 ms·
Exactly, but using a different set of syntax, plus a new ruleset of capture semantics. The capture syntax especially is a minefield. And are the runtime guarant
by fsloth 3y ago
Exactly, but using a different set of syntax, plus a new ruleset of capture semantics. The capture syntax especially is a minefield. And are the runtime guarantees exactly the same as that of a local class instance?
The question is - what does this extra complexity buy us? Is it worth it?
- fluoridation 3y ago>The capture syntax especially is a minefield. Functors are no easier to use. Either you initialize captured values through a constructor or by manually setting each member. In both cases you have to name the same values several times and ensure that you're doing it correctly. With lambdas, if capture by value or by reference is enough for everything you need, the code is much more succinct and readable. It seriously reduces useless, error-prone boilerplate. >And are the runtime guarantees exactly the same as that of a local class instance? Yes. >The question is - what does this extra complexity buy us? Is it worth it? It buys us more readable and straightforward code. Yeah, I'd say it's worth it. I haven't written a functor in years.