assignment expression peeve

Alex Martelli aleax at aleax.it
Mon Oct 20 19:17:26 EDT 2003


Carl Banks wrote:
   ...
>> "if distance divided by time, call it speed, is above 50 MPH, decelerate"
>> 
>> and, since you HAVE claimed you're not stuck on word-order
>> 
>> "if (speed := distance/time) > 50: decelerate()"
>> 
>> how CAN you claim these are ANYTHING *BUT* ANALOGOUS?!
> 
> I don't!!!  But if the programmer doesn't see "speed := ..." as "call
> it speed", then it's not a verbal equivalent, and not being one, it
> will be more difficult to read, or at least harder to learn.  Even

IF a programmer is so utterly obtuse and obdurate as to be unable
to "read" := as 'call it', 'is', 'becomes', 'which is', and so on
ad nauseam (any of the bazillion natural-language analogues I've
shown), and so narrow-minded, as you claim, that he or she will
keep stubbornly reading it as a "set to" which is NEVER appropriate,
then MAYBE that subnormal programmer will have a slightly harder
time learning ':=' than he or she has learning other constructs.

Miraculously, of course, said programmer HAS learned to "read"
e.g. % as meaning 'modulo' in some expressions and 'formatting'
in others; 2:7 as "2 maps to 7" within braces, but as "from 2
to 7" within brackets; parentheses meaning tuple here, function
call there, class inheritance yonder; and so on, and so forth --
yet that paragon of mental flexibility, so GOOD at reading the
SAME construct in different appropriate ways depending on
context, has an inexplicably localized blind spot in reading
two DIFFERENT constructs, = vs := , in two different and
appropriate ways -- truly wondrous to behold.

Yeah, well, given his/her incredibly-conveniently-located immutable
blind spot, said inDUHvidual WILL have some learning problems
connected to that one immutable blind spot.  Surprise, surprise.

I don't agree with the likelihood of any of these hypotheses
for one second (and I suspect I've taught programming to more
newbies than you have), but, no matter.  What DOES matter, is
that no shred is left of the "no analog in natural language"
assertion -- indeed, you now say:

> though it's completely analogous.

Oh *GOOD*.  COMPLETELY.  Wow, we do agree.  All that's left is
your unsupported hypothesis that programmers are likelier to
have a blind spot here than anywhere else.  I disagree.  I do
not intend to fund a study to find out, either:-).  Please find
other NON-natural-language related ways to attack your pet-hate
assignment-expression and its ilk.


Wrapping up -- I disagree that saying "a is b" is inappropriate.
You keep talking about RE-binding of name a, but that's not
necessarily what's happening.  It's also quite possible that a
had previously no binding.  In any case, the implied "from now
on, until further notice" can cancel the difference (in fact,
single-assignment languages HAVE some empirical support as
being easier to learn, if I recall correctly -- subjectively,
I recall from my very first attempt at Fortran, well over a
quarter century ago, that the ONE construct that stumped me a bit
was exactly "X = X + 1", the kind of construct that single
assignment languages deliberately do NOT have -- oh well,
anyway, just a digression).

You claim I earlier agreed that saying "a is b" does not clearly
communicate assignment.  I don't think I did, and I suspect
that if you read that into my words I may have expressed myself
in unclear ways (unless it was a blind spot on your part:-).
Sure, longer words and phrases "stand out" more, but that's a
matter of emphasis and connotation, not one of denotation.


Alex





More information about the Python-list mailing list