4 ms·
Question about (a): How do you handle special forms? I wrote a toy Lisp interpreter in Clojure, but couldn't figure out how to implement ', which I assumed sh
by bitsai 16y ago
Question about (a):
How do you handle special forms? I wrote a toy Lisp interpreter in Clojure, but couldn't figure out how to implement ', which I assumed should be implemented as a special form.
- abecedarius 16y ago'X is expanded by the reader into (QUOTE X), a special form like any other.
- bitsai 16y agoRighto. I had a working implementation that could expand 'x to (quote a) and '(1 2 3) to (quote (1 2 3)), but the case of expanding '''a to (quote (quote (quote a))) stumped me. I realize that ' is a special form like any other... except I haven't figured out how to implement any other special forms either :)
- EdiX 16y agoI handled them by generating the assembly code to implement them and setting up the symbol tables as required, I implemented ' as abecedarius said and then quote was a special form that compiled into something that "returned" the requested symbol object. PS similar deal with ` it would be expanded into a bunch of normal forms by the parser ("reader" in lisp-speak) and from there it's implemented with macros and functions, I copied Guy Steele example implementation, you can find it somewhere.
- bitsai 16y agoThanks for the tips. It's probably time for me to stop messing around and start reading the Lambda Papers in earnest...