Proposal:
For an *odd* number of forms a, x, b, ...
{a x b x c ...} => (x a b c ...)
{a x b y c ...} => (*nfx* a x b y c ...)
Reasoning:
Even after a lot of practice, prefix math is still harder (at least for
me...) to read than non-prefix math. The [], () and <> matching delimiters
are already taken, but {} is only used for an even number of forms (and, in
fact, throws an exception on an odd number of forms.)
; trumped-up examples
(defn harmonic-mean [x1 x2]
{{2 * x1 * x2} / {x1 + x2}})
(defn fib [n]
(cond
{n = 0} 1
{n = 1} 1
:else {(fib {n - 1}) + (fib {n - 2})}))
Basically, I'm claiming a solid win on readability, and no risk of breaking
any existing code.
I realize there's a certain risk of mistaking curly-infix for a map literal
when reading code, but I think it's minimal. To me, at least, {x + y} just
doesn't look like a map.
Thoughts?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.