[issue18788] Proof of concept: implicit call syntax

Nick Coghlan report at bugs.python.org
Tue Aug 20 18:49:15 CEST 2013


Nick Coghlan added the comment:

To clarify how my patch works: leaving out the parentheses is permitted
*only* when the call is a statement unto itself. That's how it avoids
conflicting with any existing syntax like "a *b" or "a **b": the parser
consumes those as part of the initial expression, so you *need* the parens
to control precedence and get it interpreted as a call instead. It was
surprisingly elegant at the implementation level - once I got the new
expr_stmt definition and parsing right, everything later in the chain "just
worked".

A real patch might want to look at the following enhancements:
* constraining the LHS further. This needs to happen at the AST
construction stage, since the parser can't look far enough ahead to limit
it. The patch currently uses the same rules as augmented assignment targets
* constraining the RHS. For example, disallowing generator expressions, so
they need to use the parenthesised form.
* adding an AST node for clean source-to-source transformations
* allowing implicit calls in more places. For example, as an assignment
value, or a return value.

Proving it was possible at all with pgen scratched my itch, so someone else
will need to run with it for it to turn into a concrete proposal that
addresses the readability issues.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18788>
_______________________________________


More information about the Python-bugs-list mailing list