> You need to explicitly specify how variables should be captured in lexical closures.
I prefer that to some "it's automagically captured" behavior (in the context of C++). At least so I know and can choose if the closure captures a reference or makes a copy - which can be a very important detail.
For the stuff I usually do in C++ I love this kind of freedom. For other stuff where speed and/or memory layout/usage are not that important there are higher level languages like Python or Common Lisp.
It seems to me that you could just as easily always create a copy of the captured variable, and in cases where you want to capture a reference, just create a reference to the variable and capture that instead. That is exactly what you see people doing when they capture "smart" pointers. You would not lose any freedom if captured variables were always copied, you would still be able to avoid expensive copy operations as needed (or just fix the problem at its source by making copying less expensive).
A high level feature like lexical closures should not get bogged down with low-level details (like the mechanics of how variables are captured). It's a waste of time and mental energy, distracting programmers from important issues and making debugging more complicated and time-consuming. Spending time deciding which method of capturing variables is faster screams "premature optimization."
I prefer that to some "it's automagically captured" behavior (in the context of C++). At least so I know and can choose if the closure captures a reference or makes a copy - which can be a very important detail.
For the stuff I usually do in C++ I love this kind of freedom. For other stuff where speed and/or memory layout/usage are not that important there are higher level languages like Python or Common Lisp.