assignment expression peeve

Mel Wilson mwilson at the-wire.com
Wed Oct 15 16:30:54 EDT 2003


In article <7xk77676bt.fsf at ruckus.brouhaha.com>,
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>I'm not sure you're correct about that.  The impression I've gotten
>when this subject has come up before is designers are terrified of
>someone saying
>
>   if x = y:
>
>when they meant ==, and causing a nuclear meltdown or something.
>Using a different operator like "x := y", avoids that problem which is
>why I did it that way in the example I gave.  However, with that
>problem removed, it's still not considered a done deal.

   More likely it's the dreaded sequence point problem,
which, in its purest form, shows up in the C statement

        arry[i] = i++;

where there's no obvious way to decide which element of arry
is going to get the new value.  A statement like

        x = (i = j * 5) + (j = i - 3)

is just too hard to make sense of.  So since it's always
been possible for a programmer to write statments that say
what's meant..

        Regards.        Mel.




More information about the Python-list mailing list