Skip to content

Associativity of matmul unclear from grammar for m_expr ย #117961

@arnoegw

Description

@arnoegw

Documentation

6.7. Binary arithmetic operations shows the grammar rule

m_expr ::=  u_expr | m_expr "*" u_expr | m_expr "@" m_expr |
            m_expr "//" u_expr | m_expr "/" u_expr |
            m_expr "%" u_expr

in which all operators except @ for matmul are left-associative (meaning, a*b*c parses as m_expr a*b and u_expr c ) while @ is ambiguous: Does a@b@c parse as m_expr a@b and m_expr c or as m_expr a and m_expr b@c?

According to PEP 465, @ should have the same associativity as *. Should this grammar rule should reflect that by saying m_expr "@" u_expr, that is, with the right-hand side changed from m_expr to u_expr?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc direasy

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions