Curious assignment behaviour
James_Althoff at i2.com
James_Althoff at i2.com
Wed Oct 10 14:00:05 EDT 2001
Tim Peters wrote:
<snip>
Oops! The assert turned out to be the perversely self-fulfilling:
assert(i = 1);
and multiple senior programmers with many decades of industrial C
experience had stared at that multiple times without realizing the mistake.
<snip>
I could certainly look at that a bunch of times and think "equality"
instead of "assignment". This is one of the reasons why Smalltalk (among
other languages) insisted on *not* using "=" to spell assignment. In my
experience, when assignment is *not* spelled with "=" such mistakes don't
come up in practice. And then it *is* acceptable (and very convenient) to
make assignment an expression.
Jim
More information about the Python-list
mailing list