Curious assignment behaviour

John Roth johnroth at ameritech.net
Wed Oct 10 17:54:29 EDT 2001


<James_Althoff at i2.com> wrote in message
news:mailman.1002736876.17796.python-list at python.org...
>
> 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

Which was exactly my point in another branch of this discussion.
It's also been pointed out that "=" is not a good symbol for assignment -
it's just the one that Fortran chose to use, and its the reason that
Algol chose ":=" as the assignment operator, with Pascal following
in that path.

In mathematics, "=" is an assertion that two expressions have the same
value over the applicable portion of the domain. Pure mathematics
doesn't have an equivalent of assignment.

However, this is a lost arguement in terms of an existing language.
Transitioning assignment to some other symbol would be a huge pain
for not very much (percieved) gain.

John Roth
>
>
>





More information about the Python-list mailing list