[Numpy-discussion] [help needed] associativity and precedence of '@'

Nathaniel Smith njs at pobox.com
Mon Mar 17 18:02:33 EDT 2014


On Mon, Mar 17, 2014 at 9:38 PM, Christophe Bal <projetmbc at gmail.com> wrote:
> Here is the translation. ;-)
>
> 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 regarding to the @-product, and
> we just do @-product from left to right.

In the terminology we've been using in this thread, this is "weak-left".

> An advantage of this is that most parsers do analyze from left to right.
>
> So I really think that it is a better choice than the weak-right one.

We've mostly ignored this option because of assuming that if we want
left-associativity, we should go with "same-left" instead of
"weak-left". Same-left is:

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

i.e., even more left-to-right than weak-left :-)

Do you think weak-left is better than same-left?

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org



More information about the NumPy-Discussion mailing list