[Python-ideas] In call grammar, replace primary with possible_call? (was Re: ...quote followed by a left parenthesis...?)
Andrew Barnert
abarnert at yahoo.com
Thu Jul 16 13:32:44 CEST 2015
On Jul 15, 2015, at 16:03, Terry Reedy <tjreedy at udel.edu> wrote:
>
> So here is the proposal: in the call definition, change primary to
> possible_call ::= identifier | parenth_form | yield_atom
> | attributeref | subscription | slicing | call
It would be fun to explain why [1,2]() is a syntax error but (1,2)() a runtime type error, and likewise for ""() vs ("")()...
Anyway, I honestly still don't get the motivation here. What makes this kind of type error so special that it should be caught at compile time? We don't expect [1,2]['spam'] to fail to compile; what makes this different? It's a lot simpler to say you can try to call any primary, and you'll get a type error if the primary evaluates to something that's not callable.
More information about the Python-ideas
mailing list