| Prescript: See section 7 of Paul Graham's "Being Popular". Especially
this: "I've used Lisp my whole programming life and I still don't
find prefix math expressions natural." The coolest hackery has beautiful mathematical gems at the core or in
the cleverest bits. And basic arithmetic is ubiquitous in
code. Mathematics, as mathematicians write it, is beautifully elegant
and concise. It is a 100-year language and then some. And it very much
embodies Paul's principles for Arc. Let's not throw that away.
There's a night-and-day difference in grokkability between the
following equivalent expressions: (+ (* 2 (f (/ x 3))) y)
2*f[x/3]+y
I absolutely appreciate the beauty of the syntaxlessness of lisp but
we need the syntactic sugar for infix. Let's take as a hard constraint
that we need to accept infix expressions, without distractions like
setting them apart with special syntax or interspersing whitespace. I
believe this means we have to give up two nice features in lisp
syntax (but that it's worth it):
1. Arithmetic symbols (+ - * / = et al) in symbol names.
2. Whitespace as element delimiters in lists.Suppose we use square brackets for s-expressions, move the first
element in front, and delimit with semicolons (whitespace is even more
insignificant than in lisp syntax, as it is no longer a delimiter): +[*[2; f[/[x;3]]]; y]
This is just as syntaxless as lisp style s-expressions, but notice how
we now have total freedom to unambiguously insert infix expressions
and use parentheses for grouping in any subexpression: +[*[2; f[x/3]]; y]
or +[2 * f[x / 3]; y]
or 2*f[x/3]+y
Some details will need to be resolved, like semicolon being the
comment character (or the obvious alternative, comma, being unquote in
macros). Also, perhaps x * y needs to be syntactic sugar for times[x;y]
rather than * [x;y] if we're to consistently forbid swearing characters
in symbol names.Do others agree that lack of infix expressions is a key barrier to
adoption of lisp (and not unreasonably, as my first example above
shows) and that we need a way to mix and match infix and prefix
effortlessly? What other ways could we achieve this? If we give up the constraint
that we shouldn't need to set infix apart with special syntax then
"sweet expressions" (http://www.dwheeler.com/readable/), where
anything in curly braces is infix, comes close. By forbidding
arithmetic characters in symbol names we can tighten it up by not
needing to intersperse whitespace everywhere: (+ (* 2 f{x/3}) y)
(+ {2*f(x/3)} y)
{2*f(x/3)+y}
The need to wrap everything in curly braces is sometimes cumbersome though.
If I want to double the result of (g 2 3) here, (f (g 2 3))
I have to do this: (f {2 * g(2 3)})
Whereas in the m-expression syntax I take this f[g[2; 3]]
and just stick in the "2 * " in the natural way: f[2*g[2; 3]]
|