[racket] Sweet expressions; or making it easier to introduce Racket to me and my coworkers :-)
On Wed, Jul 20, 2011 at 04:21:26PM -0400, Neil Van Dyke wrote:
> Not to discourage you guys, but just a factoid to keep in mind...
> 'statistically', 31.891% of Lisp programmers have experimented with
> a non-parentheses syntax for Lisp (usually to try to make the
> language more appealing to other people), and 0.001% of those
> experiments have been used in any lasting way.
>
> Also, some related work to look at in Racket: "Honu" and "P4P".
>
> One way that Honu is useful is we can point to it and say, "If you
> don't like parentheses syntax, you can use Honu instead and still
> get all the goodness of Racket!" But in practice, I think pretty
> much everyone quickly starts using paren syntax, just like they
> quickly stop trying to put each closing paren on its own line.
> There is no invisible dominatrix making them do this, but they
> decide that the conventional way is not so onerous after all, or
> perhaps even that the conventional way makes good enough sense.
> Eventually, they might come to even love the parentheses.
>
> If you want to push for a non-paren syntax that people actually use,
> then by all means do so, but I think you'll have to push very hard.
The only kind of paranthesis-avoiding syntax I've ever found to be of
any use is to have a special notation when the past element of a list is
itself a list. THen, instead of putting parentheses around that lase
element, I put a slash / in front of it. Thus
( dd ( ee ( ff gg ( hh ))))
becomes
( dd / ee / ff gg / hh )
Simple, inaambiguous, and very close to the data structure for lists.
It's kind of like another step away from the hard-core dot notation.
( dd . (( ee . ( ( ff . (gg . (( hh ' NIL)))) . NIL) . NIL)
or something like that -- I've lost count already, and yes, this is
Lisp notation, not Scheme.
It's useful when using notations like chained IFs:
( if a b
/ if c d
/ if e f
/ g h)
If other notations are altered, such as let, so it's
(let a b c)
instead of
(let ((a b)) c)
a lot of parenthheses disappear.
But the existing notation for let has evolved more or less to reduce
depth of parenthesis nesting with the existing notations for
parentheses, and they done't really fit the / suntax.
Perhaps | would have been a better symbol, or ';'.
It's similar to the awful notation someone once thought up for mass
parenthesis closing, where ] ould close all ('s until a matching [
It's similar to the awful notation someone once thought up for mass
parenthesis closing, where ] ould close all ('s until a matching [
except that you only write '/' when you intend to have the lase
element of a list, and on the awful notation you write ( for all
parentheses, leading to undetected mismatching. (which is why taht
notation is awful)
-- hendrik