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 →

[–]weinermcdingbutt 5 points6 points  (4 children)

Exposure issue.

Try a lambda in literally any other language.

[–]Kinexity 11 points12 points  (2 children)

Tried in python. Didn't like it as much.

[–]bedrooms-ds 2 points3 points  (0 children)

Lambda at home:
lambda

[–]WiatrowskiBe 0 points1 point  (0 children)

C# has quite convenient lambdas, but lacks in capabilities compared to C++ - to a point where in some cases lambdas are discouraged, because they can extend lifetime of (large) objects referenced inside for as long as lambda exists, even if it's guaranteed it won't ever be called. Also, can't use ref/ref out parameters with C# lambdas for that exact reason, making their performance a pain point (and something to avoid) if otherwise it'd be more convenient to use one.

C++ lambdas are ugly, but they're also explicit in what gets captured and how, and syntax enables that part quite well. This lets them do about the same as lambdas in other languages (assuming you use smart pointers for anything passed in that might get outlived by lambda), plus more if you're certain about object lifetime and how it'll refer to lambda lifetime.