why brackets & commas in func calls can't be ommited? (maybe it couldbe PEP?)

Terry Reedy tjreedy at udel.edu
Wed Mar 21 14:36:49 EDT 2007


You asked two questions; the first others have asked also.

Mathematicians sometimes use brackets to indicate function application and 
sometimes just juxtaposition.  When they do the latter and when there are 
things other than functions (to exclude pure lambda calculus), then there 
are usually (always?) typographic conventions to differentiate between 
function names and value names.

A common convention is value names one letter, function names multiple 
letters;  as in 'exp cos ln x'.  Note that the functions all take one arg. 
Another is that functions get capital letters, as in 'Fx'.

Without such differentiation, and without declaritive typing of *names*, 
the reader cannot parse a sequence of expressions into function calls until 
names are resolved into objects.  And if calls can return either callable 
or non-callable objects, as in Python, but rare in mathematics, then one 
cannot parse until calls are actually made (or at least attempted, and an 
exception raised).  I mention 'attempted' because in Python there is no 
certain way to be sure an object is callable except by calling it.  It is 
much more flexible and extensible than most math systems.

Other have alluded to this problem:  if you have 'f' mean what 'f()' now 
means, then you need another way to mean what 'f' now means, such as '`f' 
(quote f).  But again, Python names are not typed.  And how would you then 
indicate 'f()()' instead of 'f()'.  The math notations without brackets 
generally don't have to deal with callables returning callables.

I don't like typing ()s much either, but they seem necessary for Python, 
and become easier with practice.

As for ,s:  they are rather easy to type.  More importantly, they turn 
certain extraneous spaces into syntax errors instead of runtime bugs that 
might pass silently and give bad answers.  For instance, 'x_y' mistyped as 
'x y'.  Most importantly, making space syntactically significant either 
within call brackets or everywhere would require prohibiting currently 
optional spaces.  For instance, 'daffodils + crocuses' would have to be 
written 'daffodils+crocuses', like it or not.

Terry Jan Reedy






More information about the Python-list mailing list