logical-assignment operators

Russ Cox rsc at swtch.com
Mon Feb 12 15:06:02 PST 2007


> I realize that different people feel comfortable with
> different programming idioms, but how common is this use of &&=? Is the
> &&= operator really pulling its weight?

For one possible source of numbers, compare

  http://www.google.com/codesearch?q="||="
  http://www.google.com/codesearch?q="%26%26="

That also shows that &&= is most commonly used
for booleans like ok &&= more_work(), although the
usage John Cowan pointed out has its own small fraction.

Even though &&= is much less common than ||=,
it seems weird to have ||, &&, ||=, and not &&=.
Once ||= is in, I think &&= needs to come along.

(It might also seem weird to have && and || but not ^^,
but that's easily explained by the fact that && and || are
short-cut booleans while ^^ cannot be.)

Russ



More information about the Es4-discuss mailing list