[Python-Dev] PEP 492 vs. PEP 3152, new round
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Apr 29 07:40:21 CEST 2015
Yury Selivanov wrote:
> I don't want this: "await a() * b()" to be parsed, it's not meaningful.
Why not? If a() is a coroutine that returns a number,
why shouldn't I be able to multiply it by something?
I don't think your currently proposed grammar prevents
that anyway. We can have
<expr> --> <factor> '*' <factor>
--> <power> '*' <power>
--> <atom_expr> '*' <atom_expr>
--> 'await' <atom> <trailer>* '*' <atom> <trailer>*
--> 'await' 'a' '(' ')' '*' 'b' '(' ')'
It does, on the other hand, seem to prevent
x = - await a()
which looks perfectly sensible to me.
I don't like the idea of introducing another level
of precedence. Python already has too many of those
to keep in my brain. Being able to tell people "it's
just like unary minus" makes it easy to explain (and
therefore possibly a good idea!).
--
Greg
More information about the Python-Dev
mailing list