Re:The Lisp Curse (2011)
by greydius on Thursday February 25, 2016 @07:49PM
(#11179115)
The syntax is the same. Both are s-expressions. The difference is how a particular implementation interprets them. In this example, it would depend on the semantics of def.
[ Parent
| on HN ]
That's only the syntax of s-expressions - a data format.
The Lisp syntax is defined on top of s-expressions.
For example Common Lisp has a CASE operator. That's the EBNF syntax:
case keyform {normal-clause}* [otherwise-clause] => result*
normal-clause::= (keys form*)
otherwise-clause::= ({otherwise | t} form*)
An example: (case id
(10 (foo))
(20 (foo) (bar))
(otherwise (baz)))
The expressions are written using s-expressions as data. But still there is structure in those s-expressions, described by the EBNF syntax of CASE.Every special operator and every macro provides syntax. Since users can write macros themselves, everybody can extend the syntax. On top of s-expressions.
That is interesting. I've always considered lisp in terms of denotational semantics. In fact, I wrote a toy lisp in which the complete grammar was basically
list -> ({symbol | number | string | list}*)
and then it was up to the interpreter to decide the meaning of special forms. (I say "basically" because there was also desugaring of '(...) to (quote ...)).