4 ms·
You are correct in the sense that Scheme and C++ handle non-local variables and non-parameters differently (In C++ you can also capture variables by value, but
by pmelendez 11y ago
You are correct in the sense that Scheme and C++ handle non-local variables and non-parameters differently (In C++ you can also capture variables by value, but I don't think there is a proper free variable capture mechanism at all).
However, that's not what I meant when I wrote that. I was referring this quote:
"being able to concisely define executable "objects" (closures), inline if necessary, is very useful"
The fact that you can define inline executable objects is indeed very useful, and C++ does exactly that: an inline mangled class instantiated bounded to one variable.
It would be cool to have free variable in C++ in the same way that Scheme handles it, but I don't think the language would get there anytime soon (Gee, it is still cumbersome to have recursive lambdas).