if <assignment>:

maney at pobox.com maney at pobox.com
Sat Nov 30 16:49:53 EST 2002


Sean McSomething <ahmebah at hotmail.com> wrote:
  ...
> Of course, this could all be complete & utter bullshit, but it's a
> reasonable extrapolation from what facts I have & my understanding of
> things.

Trying to intuit the often arbitrary, or at any rate highly contingent,
reasons for what actually happened is one of those beyond-NP-hard
problems.  :-/

There are certainly some correct bits in your reconstruction: some
features are present in the C language and/or came to be commonly used
at least in part because of code size and speed considerations.  The
op-assign (+=, et. al.) were largely present to take advantage of PDP
instructions that could do that to most any two operands in one op;
even with that, though, both the desire to get that efficency with a
small, relatively brainless compiler as well as the notational
efficency were probably important factors.

In the case of operator=, I'm afraid your proposed motivation is more
of a chimera.  The real roots of this are almost certainly to be found
in C's pre-history as a simplified version of the BCPL language, in which
*everything*, including statements, had a value.  This is very likely
the original cause of both operator= and the conditional operator?:. 
The latter provides, in more limited form, something that BCPL could do
with an if/else statement inside one of it's valof blocks.

C's backstory in BCPL (by way of an even less wisely known language
named 'B') also explains the otherwise cryptic comment (by Ritchie?)
about the uncertainty over whether C's hypothetical successor (this was
before C++, but that wasn't exactly a successor to C anyway) should be
named 'D' or 'P'.  Programmer humor.  :-/

Actually, though, didn't the notion of operator= come out of Algol? 
<prayers are sent to Ghugle; his replies are interpeted>  Ooops, no,
that was just "assignment spelled differently than equality test". 
Never mind!



More information about the Python-list mailing list