Re: [Readable-discuss] wisp and readable - common expressions
Readable Lisp/S-expressions with infix, functions, and indentation
Brought to you by:
dwheeler
|
From: David A. W. <dwh...@dw...> - 2014-11-22 00:32:02
|
David A. Wheeler:
> > If wisp interpreted neoteric-expressions by default,
> > then many more expressions work in both systems...
On Fri, 21 Nov 2014 22:38:13 +0100, Arne Babenhauserheide <arn...@we...> wrote:
> That’s true, but then lines with a single element would be treated
> differently than lines with multiple elements, and that is a gotcha I want to avoid.
As I've commented before, I think the wisp rule *seems* simpler ("each line is new list"),
but in practice it is *itself* a gotcha, because it leads to bizarre behavior like this.
Which is why both SRFI-49 and sweet-expressions don't do it.
But suspending that old discussion, let's focus on the example you mentioned...
> It hits you with things like newline
> wisp:
> define : hello
> display "Hello World!"
> newline
> define : hello2 who
> format #t "Hello ~A!\n" who
If you're using wisp you probably do *not* want to use
a neoteric expression as the *first* element on a line
(unless you're actually calculating what function/procedure to call).
So teach that style rule, and you avoid that (wisp) gotcha.
However, in *both* wisp and sweet-expressions there are MANY
uses for neoteric-expressions in the REST of the line.
For example, here's a line from math.slisp:
cons car(lyst) flatten-operation(op cdr(lyst))
It's pretty common to have several short parameters on a line;
neoteric-expressions are quite useful in this case. A quick grep finds many examples.
You *can* do it using traditional s-expression notation, of course:
cons (car lyst) (flatten-operation op (cdr lyst))
However, I think the former is more readable. In particular,
the "car(lyst)" format is the same as mathematics and nearly all other
programming languages, making it much more familiar. I always use the
"car(lyst)" form when it's a call, never the "(car lyst)" form,
so there's no problem of "which format do I use".
Being readable in great part depends on building on what people already know,
and this is the more familiar notation.
Besides, neoteric-expressions are *already* supported in curly-infix.
--- David A. Wheeler
|