brendan at mozilla.org
Mon Feb 12 18:10:07 PST 2007
On Feb 12, 2007, at 6:00 PM, John Cowan wrote:
> Brendan Eich scripsit:
>>> (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";
> Yes, but when $x is 0, it remains 0.
Right -- but why would ES4 differ here? ES1-3, any old JS in a
browser, would evaluate 'x = 0; x = x && x + 5; x' to result in 0
too. I did not follow why your original post made the null initial
value case (how about undefined?) special compared to 0, false, or ''.
>> 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.
> It's good for handling mutually exclusive options. If you must
> either alpha or bravo, then alpha ^^ bravo will be alpha if alpha
> was specified, bravo if bravo was specified, and "true" if
> something is
Sure, but ^^ can't short-circuit, it's not in C, and maybe we can do
without it. I've used (alpha == true) ^ ( bravo == true) and lived.
More information about the Es4-discuss