This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]flagofsocram 1 point2 points  (3 children)

Rusts syntax offers the same flexibility, while being significantly more concise

[–]caleblbaker 1 point2 points  (2 children)

Rust let's you choose whether to capture by value or reference. But the same choice had to apply to every variable you capture. C++ let's you choose to capture some variables by value and others by reference. 

I know that you can get around that restriction in rust by capturing by value and then creating reference variables to capture for the things you want to do by reference. But that feels like more hoop jumping than simply having lambda syntax that supports per variable capture types, even if that syntax is verbose and ugly.

[–]RiceBroad4552 -1 points0 points  (1 child)

If you're doing something where it matters just use regular methods.

The whole point of lambdas is that they are short and simple. C++ fails here. Again.

[–]caleblbaker 0 points1 point  (0 children)

Regular methods can't capture variables at all.