Curly-infix and readable Lisp
Posted Dec 4, 2012 21:03 UTC (Tue) by
david.a.wheeler (subscriber, #72896)
In reply to:
Curly-infix and readable Lisp by dakas
Parent article:
GNU Guile 2.0.7 released
Poster wrote:
Lisp forms are self-descriptive simple data structures, easily juggled around and interpreted by programs and macros... infix does not change this fundamental problem of having the whole nesting of the underlying data structure exposed.
Actually, not the whole. We are likely glad not to have to write out
(+ . (3 . (4 . (5 . ())))) => 12
and instead have an alternative in- and output form for this automatically.
But conversion to infix is a different beast than converting a conventional arrangement of dotted pairs to list syntax.
I think that's the core of the disagreement. Unlike you, I believe that infix can be easily considered - and reasoned about - as just another abbreviation in Lisp-based languages. As you noted above, Lisp users are already used to other much more complex abbreviations, and abbreviations make common cases easier to deal with.
In curly-infix, {AAA op BBB op CCC ...} is just a new abbreviation for (op AAA BBB CCC ...). That's all, it's just another abbreviation.
A curly-infix user needs to be aware that this is an abbreviation, but it's really no big deal. It takes about 10 minutes or so to get used to it, and it works for any operation at all. And the payoff is big; many people prefer to use infix notation for arithmetic, comparisons, and so on. This notation really helps when communicating with others. Today's software is typically developed by many people, and in the case of open source software, being able to read others' code is key.
Thus, the Lisp expression "(car '{a + b + c})" will evaluate to "+", because {a + b + c} is another way to write the list (+ a b c), and "car" returns the first item in a list. Sure, it's odd when you've never seen this before, but it's actually easy to learn. All you have to remember is that "{...}" presents a list in infix order instead of the straightforward order, and thus, you need to look at the infix position to find the operator. Because there are no precedence rules (by intent), there's no possibility of the complex reasoning that I think you're concerned about, and the whole thing is really easy to learn.
Most software developers would prefer to be able to write {{a * b} - c} instead of having to write (- (* a b) c). Let's give them the tools they actually want.
(
Log in to post comments)