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

Robert Kern robert.kern at gmail.com
Thu Mar 20 05:07:59 EDT 2014


On Thu, Mar 20, 2014 at 4:01 AM, Andrew Dalke <dalke at dalkescientific.com> wrote:

> My preference is for same-left. I rarely work with numpy, and it's more
> likely that I'll see '@' used in a non-numpy context. That is, people
> in general will see "@" as a sort of free-for-all operator, to use and abuse
> as they wish. [1]
>
> (For example, Pyparsing has a lot of operator overloads to help make
> a grammar definition, and they make good sense in that context, but '<<'
> for recursive definitions is perhaps past the edge.)
>
> Someone looking at a "@", without any intuition on precedence or
> associativity of matrix operations in a mathematical package, will
> have to figure things out from the documentation or (more likely)
> experimentation.

I think the one thing this discussion has settled is that there is
*no* common intuition about the precedence or associativity of matrix
operations in a mathematical package. :-)

I think the operator-overload-as-DSL use cases actually argue somewhat
for right-associativity. There is no lack of left-associative
operators for these use cases to choose from since they usually don't
have numeric or bitwise operations defined for them.
Right-associativity adds some diversity into the ecosystem and opens
up some design space.

-- 
Robert Kern



More information about the NumPy-Discussion mailing list