5 ms·
The main difference is that no matter how much you re-write the syntax tree, you'll still be parsing S-Expressions, and those are as unambiguous as it gets. Ke
by Morgawr 12y ago
The main difference is that no matter how much you re-write the syntax tree, you'll still be parsing S-Expressions, and those are as unambiguous as it gets.
Keep a language simple, that's how I like it at least. It's not about how many ways are there to write X, it's more about how many times can I write the same X and have it do different things? (aka ambiguity)
The answer in Lisp is exactly one: S-Exp, obviously there are exceptions like delayed evaluation, re-binding of symbols (not really recommended, at least in Clojure) and argument parsing in macros, but those are exactly that, exceptions. Take operator overloading in many programming languages or method overriding as a comparison, way too much ambiguity.
- waps 12y agoIn LISP, I would argue that the syntax is defined only partially by the concept of S-Expressions, but by the number of different kinds of atoms that can occur as the first atom in a free S-Expression. Well, all functions only define a single syntax form, but all macros define a new syntax form that should be counted separately. Because of how LISP is structured, it is extremely tempting to have dozens of them for any reasonably-sized program. In practice, in all LISPs, this number of syntax forms is quite high. In clojure it's somewhat less, but still a lot more than in "average" programming languages.
- lispm 12y agoThat's right. S-expressions are a syntax for data. s-expressions are not the syntax of Lisp. Lisp syntax is defined on top of s-expressions. In Common Lisp there are basically four forms of syntax: * data * function calls * special forms, basic building blocks of the language. There are only a fixed number and actually very few of them. * macro forms. Many provided by the language and user extensible. The user can write new macros or extend some existing macros. The main differences between many languages and Lisp: the syntax is extensible via macros and most of the time it is relatively simple to see the implementation and the expansion of a macro. Larger Lisp systems can contain hundreds of macros or even thousands of them...