3 ms·
years ago someone posted http://norvig.com/lispy.html http://norvig.com/lispy.html here on HN I wrote a lisp in C# based on that, it was only a 100+ ish lines
by keithnz 2y ago
years ago someone posted http://norvig.com/lispy.html http://norvig.com/lispy.html here on HN
I wrote a lisp in C# based on that, it was only a 100+ ish lines of code. It was a great way to get into Lisp.
- codr7 2y agoYes, I am aware. I started out designing Forth interpreters, actually calculators and template engines, but Forth was a natural progression. My design differs a lot from idiomatic Lisp implementations (likewise Forth), and I do sometimes wonder what it would look like if you started in that end and worked your way towards supporting all the features of sharpl.
- codr7 2y agoHaving thought a bit about it, one motivation for choosing the route I did; rather than the more idiomatic one; is that it relies on pipeline of source transformations to get to optimal code. The initial expansion is often pretty sloppy. I don't do many source transformations, everything is designed to emit pretty optimal byte code on the first pass.
- dualogy 2y agoThere's also Make-A-Lisp and, unlike most write-you-a-lisp/scheme-s out there, that one also covers TCO interpretation, quasiquotation/unquote for macros and their expansion, and goes up to self-hosting: https://github.com/kanaka/mal/ https://github.com/kanaka/mal/ I just went through it over 2-3 days, great practice IMHO to do once in your life from start to finish: https://github.com/metaleap/go-lisp https://github.com/metaleap/go-lisp
- KineticLensman 2y agoConcur, although it took me two to three months, not days (was working full time is my excuse). Biggest grief point was getting macro expansion to work correctly; TCO worked almost first time, IIRC.
- codr7 2y agoUnquoting took me several implementations to wrap my head around and consistently get good enough. As did register allocation, which is more of a VM issue.
- KineticLensman 2y agoInteresting. I'm about to start doing a MAL-like again, but this time (I used C# before) using Rust and building a VM as in Crafting Interpreters rather than following the MAL guide. Macros are one of the things that I anticipate being a challenge.
- dualogy 2y agoAFAICT, their expansion still happens during an interpretation cycle — but when you "interpret" AST into your byte-code.
- codr7 2y agoOr compile, since it's usually a transformation. I like to call that the emit phase, as in emitting byte code. The interesting thing is that it only happens once, before the code is evaluated.