Shortcut operators (was Re: [MATRIX-SIG] random number
generator?)
Konrad Hinsen
hinsen@ibs.ibs.fr
Thu, 30 Oct 1997 12:11:00 +0100
> One should remember the adage that code is only written ONCE, but is read
> (by humans) MANY TIMES. The C shortcut operators are an abomination for
> code legibility, and contribute mightily to the "write-only" nature of C.
I know this is a frequently cited argument, but I don't agree. Think
about how you describe a step in an algorithm in plain English. Do you
say "increment a by one" or "set a to the sum of a and one"? I'd say
the notion of "modifying the value of a variable" is a sufficiently
basic and widespread one to be worth expressing in a programming
language.
But although I like these operators in C and C++, I wouldn't want them
in Python. To my mind they indicate "changing the value of an object",
which is not a meaningful operation on Python number types. In a
reference-based language like Python, a+=1 would have to be defined in
terms of standard assignment, and would thereby lose the
straightforward meaning of "increment a".
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________