I wrote a Lisp in F# last year, and I started with Fexprs and used them as the basis to write quasiquote and defmacro, which are then used to write things like defun and let:<p><pre><code> "backtick char ` is expanded to quasiquote by the reader"
(defmacro! quasiquote
(flambda (form)
(_qq-expand form)))
(defmacro! define-macro
(flambda (sig :rest body)
`(defmacro! ~(car sig)
(flambda ~(cdr sig) ~@body)) ))
(define-macro (defun name vars :rest forms)
`(def! ~name
(lambda ~vars ~@forms))
(define-macro (lisp/let bindings :rest forms)
`( (lambda
~(map first bindings) ~@forms)
~@(map second bindings) ))
(define-macro (let :rest forms)
(if (contains? forms :in)
`(~'clj/let ~@forms)
`(~'lisp/let ~(car forms) ~@(cdr forms)) ))
</code></pre>
There is a certain amount of brain-warping required understanding it all, and getting the nested quasi- and regular- quotes right takes some getting used to, even for me going back and trying to grok it -- but it's bootstrapping code, so once your primitives are defined, you can move on.
I am not too proud of a man to say that I read that all the way through, and by the end, still didn't understand one bit: and I'm a lisp person who at least knows a little bit about the history of the language.<p>Can ANYONE here actually
translate that into English?
I think I got lost on how exactly SUBRs and FSUBRs are different. Is it that SUBRs still get evaluated forms of the arguments in an assembly-accessible form, while FSUBRs get reader output as linked lists?