New submission from Nick Coghlan:

After watching one of the presenters at PyTexas struggle painfully with the 
fact "print value" doesn't work in Python 3, I decided I had to at least *try* 
to see if a general "implicit call" syntax was feasible within the constraints 
of the CPython parser.

The attached patch shows that it is, indeed, possible to implement such a 
syntax by modifying the definition of expr_stmt to allow for an implicit 
trailing argument list (using the normal argument syntax).

The key benefit of such a feature is that the following would once again be 
legal Python syntax:

    print "Hello world!"

Ambiguous cases (such as "expr * expr" and "expr ** expr") obey the rule that 
implicit calls are very *low* precedence, so you have to use parens to force 
the call interpretation. Similarly, a bare expression is not call - you must 
still append () to force a call without arguments.

In addition to being a pain at the interactive prompt, the change of print from 
a statement to a function has also been noted as one of the biggest problems 
with compatibility of third party user scripts for Linux distros changing the 
default system Python to Python 3. This change would mean most Python 2 print 
statements either do nothing (no arguments), produce an unexpected trailing 
newline (trailing comma) or work exactly as they do in Python 2. Only those 
that use the Python 2 redirection syntax continue to trigger a syntax error in 
Python 3.

While the *code* changes to achieve this behaviour turned out to be relatively 
small (most of the diff is in the autogenerated parser code), the documentation 
and general pedagogical impact could be substantially larger.

If there's even an outside chance this could be accepted, I'm happy to work up 
a full PEP for it.

----------
files: implicit_call_statements.diff
keywords: patch
messages: 195679
nosy: gvanrossum, ncoghlan
priority: normal
severity: normal
status: open
title: Proof of concept: implicit call syntax
Added file: http://bugs.python.org/file31381/implicit_call_statements.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18788>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to