On Wednesday, 9 March 2016 at 18:26:01 UTC, bigsandwich wrote:
Is this really true? Couldn't the closure be stored internally somewhere like std::function<> does in C++?
Lambdas in C++ creates a regular class with a call-operator, the class is instantiated and the fields filled with the "captured" variables. Isn't std::function<> just for supporting passing of lambdas etc when using separate compilation? I've never used it since I assume it is very slow. I always use function objects with a templated type in C++.
But I believe D is pointing to the activation record (stack frame) and not the individual variables. So I don't think D can capturing anything by value. Or is this wrong?