Why bother with a reader macro, when you can use a normal macro?

    (infix (2 * x1 * x2) / (x1 + x2))

IMO, the times when it makes sense to use infix notation are fairly few,
anyway. One could write the above as:

    (/ (* 2 x1 x2)
       (+ x1 x2))

Which to me actually seems more readable than the infix version.

The other problem with your proposal is that Clojure's reader is almost all
about parsing data. What data does this infix notation represent? It
doesn't represent anything new, just a different way of writing lists.

Imagine if you proposed something similar for JSON. Would it make sense to
have an infix notation syntax for a data-only syntax? If not, then it
probably doesn't make sense for Clojure.

- James


On 4 April 2014 05:17, Joshua Brulé <jtcbr...@gmail.com> wrote:

> 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 clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> 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 clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to