[ prog / sol / mona ]

prog


"Lisp has no syntax"

1 2021-10-10 14:49

Why do some Lisp enthusiasts like to make the dubious claim that "Lisp has no syntax"?

It is clear Lisps are chock-full of syntax. Examples for Common Lisp:

* Plenty of parentheses.
* Loop macros
* Format string specifications
* Reader macros: #', #:, #=, etc.
* Examples of invalid syntax, demonstrating that Lisp does have syntax:
* (if 1 2 3 4)
* (loop while)
* (defun f (&key &key))
* (let ((x 1)) x (declare (fixnum x)))
* etc, etc, etc.

2 2021-10-10 16:33

Because originally Lisp was going to be written in m-expression syntax which the parser would turn into s-expressions, which are a very simple kind of AST. I think. But before they got the parser written, people had already gotten used to writing code in s-exprs, and preferred them to m-exprs.

3 2021-10-11 00:21

>>2

So then the parser ["read"] just has to be able to take a textual representation of s-exprs, and turn it into their in-memory representation (and run any reader macros).

But anyway, I think people say that because the job of the parser (especially if you ignore reader macros, and if you just look at it on a surface level) seems very simplified compared to what the parser for a lot of languages does to generate the AST, because you already have a textual representation of the AST.

On the other hand, lisp is often described as having read-time, compile-time, and run-time, and compile-time itself (sometimes) gets described as having a macro-expansion phase, and then a later phase, and handling a lot of what is syntax in other languages (I think) gets put off until macro-expansion time.

4


VIP:

do not edit these