skuwamot at adobe.com
Mon Feb 12 14:51:36 PST 2007
Hi folks. Just to introduce myself... I'm new to this list, but I've
provided feedback on the ECMAScript spec to folks like Jeff Dyer within
Perhaps this is just a matter of programming style, but
x &&= x + 5
seems cryptic to me, and I personally would prefer
if (x != null)
x += 5;
in my own coding. 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? To my eye, it doesn't add a huge
amount of benefit, and could probably be left out of the language.
> -----Original Message-----
> From: es4-discuss-admin at mozilla.org
> [mailto:es4-discuss-admin at mozilla.org] On Behalf Of Brendan Eich
> Sent: Monday, February 12, 2007 1:22 PM
> To: John Cowan
> Cc: Steve Yegge; es4-discuss at mozilla.org
> Subject: Re: logical-assignment operators
> On Feb 12, 2007, at 12:51 PM, John Cowan wrote:
> > 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.)
> '' is false in Perl, so this worksforme in Perl:
> $ perl
> my $x;
> $x &&= $x + 5;
> print "$x\n";
> Is that what you meant?
> BTW, I'm in favor of &&= and ||= now that I think for three seconds
> about the || use cases I know, which really wanted ||= all along.
> One pill that we spat out along with these, perhaps it was the only
> poison: ^^ (and ^^= if ^^ is there). Does anyone have a use-case for
> value-preserving ^^? We didn't think so when TG1 last considered
> these oddments from Waldemar's draft js2/es4 proposals.
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
More information about the Es4-discuss