3 ms·
No, Lisp syntax is not all the same. 'if' has the syntax if test-form then-form [else-form] 'cond' has the syntax cond {clause}* => result* clau
by lispm 17y ago
No, Lisp syntax is not all the same.
'if' has the syntax
if test-form then-form [else-form]
'cond' has the syntax
cond {clause}* => result*
clause::= (test-form form*)
'case' has the syntax
case keyform {normal-clause}* [otherwise-clause] => result*
normal-clause::= (keys form*)
otherwise-clause::= ({otherwise | t} form*)
LOOP has a full page of syntax.
http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm#loop http://www.lispworks.com/documentation/HyperSpec/Body/m_loop...
What you think has 'no' syntax, is the syntax for s-expressions. S expressions are relatively trivial, but not every s-expression is a valid Lisp form. S-expressions are a syntax for DATA.
The syntax of Lisp, the programming language, is described on top of s-expressions. Syntax is concerned with the structure of valid expressions of a language. So you have an additional layer of syntax which describes, on top of s-expressions, the syntax of Lisp.
There is some basic syntax:
* data like numbers, strings are valid Lisp programs
* function calls are valid Lisp programs. Function calls have a non-trivial syntax with rest, optional and keyword args, lambda functions, ...
* special forms like CATCH, FLET, IF, QUOTE, SETQ, ... all have their defined syntax
* macro calls, here the macro has to implement the syntax specified in the standard. users can do with their macros what they want.
For example
(if (foo-p) (this) (that) (these))
is a syntax error, though it is a valid S-expression.
Similar
(loop for i below 10 (print i))
is also wrong. Correct would be for example
(loop for i below 10 do (print i))
So, what you may want is to remove the data syntax (s-expressions) from Lisp and replace it with some other layer of syntax that is not based on prefix parentheses-heavy s-expressions.
There are lots of languages that have different syntactical approaches. Lisp has its own, which makes it slightly unusual (the syntax is used to support the code-is-data paradigm), less popular, but also makes sure that it will find its users - those users who want a language with a flexible syntax (one that can be extended by the developer) on top of a simple data syntax.