2 ms·
Isn't the distinguishing feature of a closure that it can capture stuff from the environment? > Unlike a plain function, a closure allows the function to acces
by abeppu 3y ago
Isn't the distinguishing feature of a closure that it can capture stuff from the environment?
> Unlike a plain function, a closure allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.
> The term closure is often used as a synonym for anonymous function, though strictly, an anonymous function is a function literal without a name, while a closure is an instance of a function, a value, whose non-local variables have been bound either to values or to storage locations (depending on the language; see the lexical environment section below).
My understanding is that your use of 'capture' matches up with the the use of 'bound' in the description above.
https://en.wikipedia.org/wiki/Closure_(computer_programming) https://en.wikipedia.org/wiki/Closure_(computer_programming)
- proto_lambda 3y agoIt can capture things, OP's example does not capture anything.
- evntdrvn 3y agopeople casually using the term closure for anonymous functions has caused so much confusion over the years lol