Re:Not Lisp again (2009)
by Sharlin on Tuesday May 02, 2017 @03:28PM
(#14249752)
Passing function addresses as parameters is easy. It's more difficult to return a nested function that closes over the outer function's variables.
[ Parent
| on HN ]
Not really in machine language or even BASIC (see below).
Your BASIC example doesn't have any local variables to close over. It just references a global. That defeats the whole point of closures.
Passing or returning first-class functions aren't a problem. First-class closures (function pointer + state) are.
You can create closures in CBM BASIC V2 by referencing arrays or creating thunks as an extension. But that's beside the original point. Implementing is not a lot of work but since my mega-deriver already solves the problem (derivation) elegantly and efficiently (most likely more efficiently than the original m68k lisp program), I really don't see any reason to use closures here. Do you?