Hacker News new | ask | show | jobs
by Blikkentrekker 1854 days ago
This isn't necessarily true, as various special forms have keywords with special meaning themselves that are enclosed in parentheses.

This is a complete Scheme program:

  (cond
    [(= 1 0) (error "should be unreachabe")]
    (else    "should always be reached"))
However this:

    (else    "should always be reached")
Is not a Scheme program, unless the binding `else` be defined in the current scope..
2 comments

It is for this reason that it is misleading to say that lisp languages "have no syntax" - they do have considerable constraints on their structure. It's almost as if there's a third layer between "syntax" and "semantics" - or perhaps the word "syntax" conceals two distinct types of structure.
'syntax' is actually a useful term in this context. But this syntax works on token tree data. The token trees is the code as s-expression data.

The Lisp syntax then is defined for these token trees.

For example the syntax for an argument list in Common Lisp is defined with an EBNF syntax description form:

  lambda-list::= (var* 
                  [&optional {var | (var [init-form [supplied-p-parameter]])}*] 
                  [&rest var] 
                  [&key {var | ({var | (keyword-name var)} [init-form [supplied-p-parameter]])}* [&allow-other-keys]] 
                  [&aux {var | (var [init-form])}*])
The XML people came up with the word "schema" for the remaining shape of a datum when the details of recovering the tree itself from the tokens are settled.
Is the second one less of a program than (frobnicate "foo")? Looks about the same to me: a program that crashes unless we (define frobnicate …) first.
Crashes? in most cases simply does not compile because Scheme has static scope; it is thus not a program.

But, we can of course go even further than that:

   (library (main constants (0 0 1))
     (export pi)
     (define pi 3.1415926535)
   )
`(0 0 1)` is not a valid Scheme program, no matter what one define at any point; an integer can never be the operand of an expression.