archives

Resolved Debates in Syntax Design ?

In the spirit of the What Are The Resolved Debates in General Purpose Language Design? topic, I would be interested in hearing your opinion on the specific Syntax Design problem. In designing a new syntax for a programming language, what are the decisions that are objectively good (or bad) ?

Most syntaxic questions are rather subjective (for example, 'CamelCase' or 'with_underscores' identifiers ?), but I think that some can be answered definitely with a convincing argumentation.

Here is one example : recursive scoping should always be optional and explicit. Recursive scoping is when a defined identifier scope is active at the definition site as well as at the usage site. In Haskell, term definitions have recursive scoping by default, while OCaml doesn't (there is a let .. and a let rec ... syntax). It allows for useful programming idioms such as let x = sanitize x in ... or let (token, i) = parse i. Haskell programmers would sometimes benefit from such a possibility, as can be seen here and here. type definitions are implicitely recursive in OCaml and this is also a pain.

Example of debates that are probably not resolved (yet ?) :

  • identation-sensitive syntax
  • open (if .. else ..) or closed (if .. elif .. else .. end) conditional statements

Do you know of ressources discussing such syntaxic issues in a general way applicable to numerous/all (textual) programming languages ?

Question on top-level (and other) environments

In Lisps, where definitions, expressions, and syntax transformers can be mixed freely in a block of code, the semantics of environments become a bit complicated, I think.

R6RS's expansion process is the best and most clearly described semantics for such blocks that I know.

In effect, a block of code is transformed into a letrec*, with dummy bindings for expressions that are between definitions. Furthermore, the syntax transformation of the right-hand sides is delayed until all definitions in the block have been seen.

This seems sensible, but I wonder if anyone has pointers, information, or rationale for R6RS's and other possible approaches to the semantics of such environments?

Thanks