4 ms·
> C++ version needs a complicated capture syntax C++ doesn't actually need it. Rust proved that capture everything by reference or capture everything by move i
by lightgreen 7y ago
> C++ version needs a complicated capture syntax
C++ doesn't actually need it. Rust proved that capture everything by reference or capture everything by move is enough for all practical use cases.
C++ lambdas is another example where C++ committee chose complex uber-universal solution instead of much simpler which solves 99% use cases.
- adev_ 7y agoThat's wrong. C++ object lifetime management is much more tricky and error prone than the Rust one. Passing an object by reference to lambda by default can be a beautiful source of out of scope and default. The committee did an excellent job by allowing explicit filtering.
- masklinn 7y ago> C++ doesn't actually need it. Rust proved that capture everything by reference or capture everything by move is enough for all practical use cases. That's kinda true but kinda not: precise "capture clauses" is a common design pattern in rust[0] showing that the flexibility is extremely useful, and I think I've seen rumblings about adding them to the language. I mean technically you only ever need `move` closure, "ref" closures are already a convenience. [0] http://smallcultfollowing.com/babysteps/blog/2018/04/24/rust-pattern-precise-closure-capture-clauses/ http://smallcultfollowing.com/babysteps/blog/2018/04/24/rust...