Skip to content

Is it feasible to get some syntactic sugar for capturing the value only once? #9404

Answered by jaredpar
voroninp asked this question in Q&A
Discussion options

You must be logged in to vote

In the past we've discussed the idea of adding a modifier that would cause closures to capture by value instead of by reference. These are tweaks that exist in other languages like C++. That would provide the semantics that you want in this particular case.

The general feeling though was that it's not worth the conceptual trade off to add to the language.

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@GabeSchaffer
Comment options

@voroninp
Comment options

Answer selected by voroninp
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@voroninp
Comment options

@The-Futurist
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants