3 ms·
So, here's a fun example: a self-hosted Lisp. Copy this: https://gist.github.com/anonymous/af755d7cf0f71a574f39f547d3357a39 https://gist.github.com/anonymous/a
by sillysaurus3 10y ago
So, here's a fun example: a self-hosted Lisp.
Copy this: https://gist.github.com/anonymous/af755d7cf0f71a574f39f547d3357a39 https://gist.github.com/anonymous/af755d7cf0f71a574f39f547d3...
And paste it into the VM: https://cdn.rawgit.com/vvanders/wasm_lua/d68f46a8/main.html https://cdn.rawgit.com/vvanders/wasm_lua/d68f46a8/main.html
It's a modified version of Lumen (https://github.com/sctb/lumen https://github.com/sctb/lumen) made to run on this VM. It defines a runtime, a reader, a compiler, then compiles the runtime from Lisp to Lua and prints out its own source code.
Lumen is also capable of compiling to JS, and I wanted to show it printing out its own source code as JavaScript instead of Lua. But unfortunately I was getting some strange WASM-related memory errors when compiling as JS, so I decided to settle for a neat demo that everybody can run.
(The demo could be a little less cryptic, and I could do a better job of explaining it, but it's late.)
- vvanders 10y agoThat's really cool(and kinda meta!). I love how multi-paradigm Lua is, we used to do component based composition with metatables but I've seen OO inheritance and a slew of other approaches as well.