python / python/cpython

Associativity of matmul unclear from grammar for m_expr

未關閉
#117,961 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

docs easy
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

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
  • gh-138847
  • gh-145636
  • gh-149281

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中連結的「6.7 Binary arithmetic operations」章節開始,將其 m_expr 文法與 PEP 465 中指定的結合性進行比較。檢視連結的 PR gh-138847、gh-145636 和 gh-149281;完成的條件是文件明確說明 @ 的結合性,並與規格一致。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
documentation
Issue 類型
文件
難度
1/5
預估耗時
1 小時以內
活躍度
停滯
描述清晰度
描述清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。