new python syntax: concatenation of functions

Bob Lancaster boblancaster at zxmail.com
Thu Mar 11 19:24:14 CET 2004


Uwe Mayer <merkosh at hadiko.de> wrote in message news:<c2pj49$ej3$1 at news.rz.uni-karlsruhe.de>...
> Hi,
> 
> I know the python community is not very receptive towards extending the
> python syntax. Nevertheless I'd like to make a suggestion and hear your pro
> and cons.
> 
> I want so suggest a concatenation operator like in mathematics: °
> such that: 
> 
>     a(b(c(d))) <=> a°b°c(d)
> 
> Now, why do you think such an extension would be completely useless? ;)
> 
> Ciao
> Uwe

One of the things I like best about Python is the ease of use.  This
method would hurt, rather than help the cause, IMO.

Here are the arguments against it:

(1) Where is the ° key on the keyboard?  I do chemistry related
programing, and getting the ° into my GUIs (when I need to show
degrees) takes a bit of time and effort.  The old way is easier to
type, ergo easier to use.

(2) The precedence and ordering of the operation would have to be more
clearly defined.  This seems similar to the Unix pipe | operator. 
However, in your proposal the result of c(d) is piped into b, and that
result is piped into a.  This could lead to confusion.  Should we have
a pipe-style °, in which case the syntax would be:  c(d)°b°a, or do
the way you suggest: a°b°c(d).  Either way would be confusing to
somebody.  (As far as using | to get around the problems with point
(1),

(3)  How would this operator play with other operators? 

(4) For my personal style, I don't like to use constructs that are too
esoteric.  I tend to avoid the tertiary operator in C++, and I tend
not to get fancy with the 'and' and 'or' operators in Python.  It
makes code more readable and maintainable, IMO.  Any programmer who
writes code without any thought to code maintainance is doing the
employer or client a disservice.

(5) One of the best aspects of Python is how easy it is to learn in
the first place.  Someone with a background in C/C++, Java, Pascal,
Perl, etc. can learn python in a few hours.  Adding weird operators
would make the process more difficult.  Anyone who has been though
language Holy Wars knows that ease of use and learning is about the
only way to convince anyone to even consider Python.

Just my opinions.

-Bob



More information about the Python-list mailing list