||= is much needed?

Aymeric Vitte vitteaymeric at gmail.com
Wed Jun 13 03:12:41 PDT 2012


Indeed, maybe both should be included.

What about this case :

if (typeof(api)=="undefined") {try later} else if (!api.a) {try later} 
else if (!api.a.b)) {try later} else if (etc...)

which can be written : if 
(!(((typeof(api)!="undefined"?api.a:undefined)?api.a.b:undefined)?api.a.b.c:undefined)) 
{try later}

but can't be written with ?:

The best in that case would be to be able to do : if (!api.a.b.c) {try 
later}

Why in accessors the attempt to access a property of |undefined| could 
not return |undefined| itself ?


Le 13/06/2012 09:45, T.J. Crowder a écrit :
> On 13 June 2012 06:52, Brendan Eich <brendan at mozilla.org 
> <mailto:brendan at mozilla.org>> wrote:
>
>     People don't default on the caller side (at the callsite) much, in
>     my experience. Dave may be seeing other sources, but it's
>     extremely rare in my experience to see
>
>
> I'm with Dave on this, I do it fairly regularly, usually when a 
> function turns around and calls another one with the arg and has no 
> other use for the arg:
>
> function doSomethingNifty(a, b) {
>     return doSomethingVerbose({
>         x: 1,
>         y: a,
>         z: b ?: 5
>         // ...
>     });
> }
>
> ?= looks great, and Wes' point about confusion re ||= (or even |||=) 
> and boolean logical operators definitely kills my preferred ||| for 
> the non-assignment form if there's going to be an assignment form -- 
> and we all want an assignment form.
>
> Is the reason for using ?: rather than ?? because we may want it for 
> my desired second ternary? E.g., from my other message:
>
> a = b ?? c : d;
>
> meaning
>
> a = b !== undefined ? c : d;
>
> Or that we want it (now, or in reserve) for something else? Because if 
> not, I'd prefer to see ?? rather than ?:. It's easier to type and the 
> double ?? calls back to the related ||. But again, only if we don't 
> want ?? (now, or in reserve) for something else.
>
> Very much looking forward to ?: (however we spell it) and ?=.
>
> -- T.J.
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-- 
jCore
Email :  avitte at jcore.fr
Web :    www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120613/63e6b2e3/attachment.html>


More information about the es-discuss mailing list