[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposed grammar change: forbid lines with >1 n-expr that end with "."

This page is part of the web mail archives of SRFI 110 from before July 7th, 2015. The new archives for SRFI 110 contain all messages, not just those from before July 7th, 2015.

I'm proposing a minor grammar change, and want to know of any objections.

Currently, in sweet-expressions, if a line has more than one neoteric-expression
and the last expression is ".", the "." is interpreted as the symbol
whose spelling is the single character ".".  E.G.:
quote .
=> (quote |.|)

I propose making this an error instead, to improve error detection.
It's fairly unusual to want this on *purpose*.  Usually "." introduces
the cdr of a pair. This would detect accidental use, if you *wanted* to do this,
you'd then have to escape it - say like this:
quote |.|
=> (quote |.|)

The grammar change is trivial, and makes the grammar simpler. In ANTLR/Java:
 rest returns [Object v]
-  : PERIOD /* Improper list */
-      (hspace+  pp=post_period {$v = $pp.v;}
-       | /*empty*/   {$v = list(".");})
+  : PERIOD hspace+ pp=post_period {$v = $pp.v;} /* Improper list */

A period on a line by *itself* would continue to mean that the next
line (at the same indent level) is the cdr of the given list.

Any objections?  I plan to check this into the development branch, so
we can experiment with it, but it'll be easy to pull out if there are objections.

--- David A. Wheeler