That's an interesting idea, but on the other hand, if you don't have precedence defined for the common cases, how are infix expressions better than prefix? Does it save typing and cognitive load?
{1 + {2 * 3}}
(+ 1 (* 2 3))
Maybe it's a bit clearer, as it's more familiar. Could this be extended to arbitrary two-parameter functions?
(def foo (x y) ...)
{x foo y} ; --> (foo x y)
Why do I ask? Because then we would have a way to write
; "Object-oriented" method call
{object -> method}
; Different kinds of assignments, common in C/C++/Java/etc.
; (Perhaps of little worth in Arc.)
{x += 1}
{x -= 1}
{x |= bits}
; A "binding" operator, or Pascal-like assignment.
{x := 1}
; An arbitrary relation.
{a R b}
; Perl 6 pipe operator [1] look-alike.
{{data ==> [...]} ==> processed}
> Maybe it's a bit clearer, as it's more familiar. Could this be extended to arbitrary two-parameter functions?
This is, in fact, the reason why dwheeler decided to eschew precedence - I kept pestering him that in the future I might want to create a 'convoke operator or some other arbitrarily-named relation. Basically any {_ sym _ [sym _]...} pattern gets converted to (sym _ _ ...)
The problem with supporting precedence is that you have to define it before someone starts mixing up the order of the symbols. And dwheeler wanted to do it at read time, so you had to have fixed precedence at read time. If someone randomly typed {x sym1 y sym2 z}, the reader wouldn't be able to know if it's (sym1 x (sym2 y z)) or (sym2 (sym1 x y) z). Initially we were thinking of supporting only +-*/ precedence and disallow mixing of other operators, but this started to get slippery: where do you draw the line where some operators are allowed to have precedence and others are not?
This suggestion may be a bit un-Arc, but I'd prefer a "with-infix" macro implementing a well-defined sub-language than I would some kind of integration into the reader. An optional precedence list arg might be a good idea.
The problem there is, of course, that the s-exprs generated by the macro are essentially a black box, but in my thinking, if infix is being used minimally and purely for convenience's sake, it isn't necessary to make those s-exprs accessible to other macros (right?...).