3 ms·
So are these "specials" being parsed by a grammar? Would be interesting to see how the interpreter works actually... I would guess it checks what `defun` is,
by erlich 3y ago
So are these "specials" being parsed by a grammar?
Would be interesting to see how the interpreter works actually...
I would guess it checks what `defun` is, which is a macro...then expands it, and the expansion should ultimately result in an s-expression, which is then parses? Is this right?
- coldtea 3y ago>Would be interesting to see how the interpreter works actually... It's quite easy to see, there are interpeters for Lisp in like 20 lines or so. Here's a good one: https://norvig.com/lispy.html https://norvig.com/lispy.html (It has the full code in a link towards the bottom) There's also this: https://github.com/kanaka/mal https://github.com/kanaka/mal > I would guess it checks what `defun` is, which is a macro...then expands it, and the expansion should ultimately result in an s-expression, which is then parses? Is this right? Yes, but macros (like special forms, but macros can be user implementable) have some "special" powers regarding controlling the evaluation of the code they produce. Here's some more discussion with examples: https://stackoverflow.com/questions/42470940/how-is-the-defun-macro-implemented-in-lisp https://stackoverflow.com/questions/42470940/how-is-the-defu...
- erlich 3y agoThanks! Lisp is so damn cool.
- lispm 3y ago(defun foo (a) (+ a 1)) is a s-expression. For evaluation Lisp expands the DEFUN macro then and this returns a new s-expression. Which then is evaluated. > So are these "specials" being parsed by a grammar? Every special operator (and there are only a limited amount and this is not user extensible) needs to be implemented by a Lisp source interpreter or a Lisp compiler. Other tools like a code walker also need to know the syntax.