Sweet-expressions are a new proposal for whitespace-controlled infix
syntax for Scheme and other Lisps. Unlike existing proposals right
back to the beginning of Lisp, sweet-expressions are fully homoiconic,
so they need no updating to work well with arbitrary syntax extensions.
There is a simple escape back to S-expressions: just put things in parens.
There is a formal definition of sweet-expressions in BNF, as well as
working Scheme code that can be dropped in as a replacement for `read`.
Here's a simple procedure definition written as a sweet-expression.
define represent-as-infix?(x)
and
pair? x
is-infix-operator? car(x)
list? x
{length(x) <= 6}
An empty line at the end terminates the sweet-expression. The notation
f(x), with no whitespace before the "(", means (f x). Note the use of
braces to delimit an infix expression.
Here's another example, using the special lexical syntax $, which
indicates that its right-hand side is the last element of the list begun
by its left-hand side. It is named by analogy with the $ operator in
Haskell: a $ b $ c $ d means (a (b (c d)).
define extract(c i) $ cond
vector?(c) $ vector-ref c i
string?(c) $ string-ref c i
pair?(c) $ list-ref c i
else $ error "Not a collection"
If you are interested, send a blank email with the subject line
"subscribe" to <
srfi-110...@srfi.schemers.org>. I'll be there.
(Note to David and Alan: the link to the source is broken.)
--
John Cowan
co...@ccil.org http://www.ccil.org/~cowan
Most languages are dramatically underdescribed, and at least one is
dramatically overdescribed. Still other languages are simultaneously
overdescribed and underdescribed. Welsh pertains to the third category.
--Alan King