logical-assignment operators

John Cowan cowan at ccil.org
Mon Feb 12 12:51:33 PST 2007


Steve Yegge scripsit:
> Hi folks,

> A little bird told me that TG1 may have dropped support for the
> assignment operators &&=, ||=, ^^= due to lack of popular demand and/or
> compelling use cases.
> 
> If so, I thought I'd lobby to get at least ||= added back in.

I agree, and I think there is a use case for &&= as well.  Suppose
that x is either an integer or null.  Then

	x &&= x + 5;

will increment x by 5 unless it is null, in which case it will be
left alone.  (This will not work in languages where 0 is false,
like C and Perl.)

-- 
Clear?  Huh!  Why a four-year-old child         John Cowan
could understand this report.  Run out          cowan at ccil.org
and find me a four-year-old child.  I           http://www.ccil.org/~cowan
can't make head or tail out of it.
        --Rufus T. Firefly on government reports



More information about the Es4-discuss mailing list