"You Won't Believe This One Weird Way to Rewrite Closures" by Jonathan Martin
This talk was an exercise in writing a closure implementation in JS from scratch.
Most of this talk was live coding with TDD. The best way to see how it works is to check the code repo or the interactive transpiler.
- Rewrite closures, sort of like the way React rewrites the DOM with its virtual DOM
- Ground rules
- No variables or function parameters
- No memoization (functions are amnesic)
- Can access a single global variable
- Shortcut for setting/getting local variables
- API
s(name, val)
to set a variableg(name)
to get a variable's valuef(name, params, body)
to create a function