Hello,
and what about something like that ?

a @ b @ c  ->  (a @ b) @ c
a * b @ c  ->  (a * b) @ c
a @ b * c  ->  a @ (b * c)

Easy to remember. The *-product has priority to @-product, and then we just to @-product from left to right.

An advantage of this is that parsers do job from left to right so I realy think that is a better choice than the weak-right.

Christophe BAL



2014-03-17 21:37 GMT+01:00 Russell E. Owen <rowen@uw.edu>:
In article
<CAPJVwBkLww7-ysZB76LMRZ+mmbyN_5T=ym_VU1pJGakRLBqOkw@mail.gmail.com>,
 Nathaniel Smith <njs@pobox.com> wrote:

> OPTION 1 FOR @:
> Precedence: same as *
> Associativity: left
> My shorthand name for it: "same-left" (yes, very creative)
>
> This means that if you don't use parentheses, you get:
>    a @ b @ c  ->  (a @ b) @ c
>    a * b @ c  ->  (a * b) @ c
>    a @ b * c  ->  (a @ b) * c
>
> OPTION 2 FOR @:
> Precedence: more-weakly-binding than *
> Associativity: right
> My shorthand name for it: "weak-right"
>
> This means that if you don't use parentheses, you get:
>    a @ b @ c  ->  a @ (b @ c)
>    a * b @ c  ->  (a * b) @ c
>    a @ b * c  ->  a @ (b * c)
>
> OPTION 3 FOR @:
> Precedence: more-tightly-binding than *
> Associativity: right
> My shorthand name for it: "tight-right"
>
> This means that if you don't use parentheses, you get:
>    a @ b @ c  ->  a @ (b @ c)
>    a * b @ c  ->  a * (b @ c)
>    a @ b * c  ->  (a @ b) * c
>
> We need to pick which of which options we think is best, based on whatever
> reasons we can think of, ideally more than "hmm, weak-right gives me warm
> fuzzy feelings" ;-). (In principle the other 2 possible options are
> tight-left and weak-left, but there doesn't seem to be any argument in
> favor of either, so we'll leave them out of the discussion.)

After seeing all the traffic on this thread, I am in favor of
"same-left" because it is easiest to remember:
- It introduces no new rules.
- It is unambiguous. If we pick option 2 or 3 we have no strong reason
to favor one over the other, leaving users to guess.

To my mind, being able to easily reason about code you are reading is
more important that hoping to increase efficiency for one common case
when not using parenthesis.

It also has the advantage that it needs the least justification.

-- Russell

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion