> 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))

I find this a very convincing counter-argument, in general. (I also think 
the random examples I cooked up were a poor demonstration.)

But it still seems to me that in the case *exactly three forms* - binary 
function and arguments - curly infix can be a solid improvement on 
readability.

(map (fn [x] (cond (zero? {x mod 15}) "FizzBuzz" 
                   (zero? {x mod 5}) "Buzz"
                   (zero? {x mod 3}) "Fizz"
     :else x))
     (range 1 101))

;; curly-infix also seems to be a natural fit for core.logic relations, e.g.

(all
  {x membero coll}
  {x != some-val})

To me, it's like using '(forms) instead of (quote forms) or #(some-function 
%) in place of (fn [x] (some-function x)). Clojure's reader is almost all 
about parsing data, but certain redundant notations are there to improve 
readability for special cases. 

I am, of course, open to the possibility that this is just another thing 
that LISP programmers get used to over time. Every *other* time I tried to 
improve LISP syntax (e.g. off-side rule), I pretty quickly realized that 
the proposed improvement was, in fact, a detriment to the language. But 
curly-infix still seems like an improvement to me. (Although, I'm 
rethinking this, given the initial reaction of everyone else...)

On Friday, April 4, 2014 2:24:44 PM UTC-4, James Reeves wrote:
>
> 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é <jtcb...@gmail.com <javascript:>>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 clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> 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+u...@googlegroups.com <javascript:>.
>> 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