[Python-ideas] Fwd: Make parenthesis optional in parameterless functions definitions
tritium-list at sdamon.com
Fri Apr 1 10:36:27 EDT 2016
On 3/31/2016 19:22, Ben Finney wrote:
> No mention of keystrokes. I'm endlessly disappointed that discussions of
> “too much noise in the code” are mis-interpreted as*only* about
> writing, not about reading.
Because, presumably, the people making those comments read a lot of code
and don't see a problem with the two characters?
>>> def foo():
There are four pieces of information in the first line of that
definition. It starts with the keyword at the beginning of the line.
Readers of languages that are left to right will instantly know they are
in a function definition. The next piece of information is the
identifier that the function will be assigned too, and that is clearly
defined right there. The proposal would not change this. The third is
the argument list, in this case an empty one. The fourth is the 'block
delimiter' for lack of anything better for me to call it.
As this example sits, that line should be read as "define a function
named foo that explicitly takes no arguments with the following code."
Omitting the parens changes the way it reads to something along the
lines of "define a function named foo with the following code." The
proposal has removed vital visual information.
I said earlier that if this suggestion was made in 1991 it should have
been accepted to make functions more consistent with classes. I have
changed my mind; in 1991 classes should have been corrected to always
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas