logical-assignment operators

Lars T Hansen lth at acm.org
Tue Feb 13 01:07:53 PST 2007


On Feb 13, 2007, at 3:56 AM, John Cowan wrote:

> Brendan Eich scripsit:
>
>>> 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  
>> ''.
>
> Brain fart on my part (comes of knowing too many languages with  
> imperfect
> recall of the details).  Yes, that's flaky in any language where
> zero is false, including Javascript.
>
>> 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.
>
> That works when alpha and bravo are booleans, but not when they are
> richer values.

The use of == implies a rich set of conversions, so this probably
works well most of the time.  But a proper definition of ^^ would leave
less to chance.

--lars

> OTOH, if they are richer values, you probably still
> want to keep track of which is which rather than just merging them.
> Concedo.
>
> -- 
> Only do what only you can do.               John Cowan  
> <cowan at ccil.org>
>   --Edsger W. Dijkstra's advice
>     to a student in search of a thesis
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss




More information about the Es4-discuss mailing list