3 ms·
I'm embarrassed to admit it took me a while to make sense of that code snippet. Now, in order for it to work, a language has to support closures, not just func
by throw_m239339 6y ago
I'm embarrassed to admit it took me a while to make sense of that code snippet.
Now, in order for it to work, a language has to support closures, not just functions.
- Twisol 6y ago> Now, in order for it to work, a language has to support closures, not just functions. Objects are a reasonable stand-in for closures. Pass in the first batch of arguments to the constructor, and store them as fields. Access them from the method (which plays the role of the "returned" closure) when it's called later. (This is effectively the same as "closure conversion" in the literature, but we're taking advantage of the implicit-receiver convention to hide the parameter by which we're passing the prepared fields.)