||= is much needed?

Aymeric Vitte vitteaymeric at gmail.com
Thu Jun 14 16:06:22 PDT 2012


This discussion I think is going into a useless complexity.

Nobody (except w3c) is using null, or when someone is using it, it is 
the same way as undefined, and it is not explicit (ie a||b or a==b, not 
a===null), I remind some old code where we could see the use of null but 
can not find a single example of recent code, then the new operator(s) 
should treat it the same way I believe, the problem is 0 here

Le 14/06/2012 23:16, Rick Waldron a écrit :
>
>
> On Thu, Jun 14, 2012 at 3:45 PM, Brendan Eich <brendan at mozilla.com 
> <mailto:brendan at mozilla.com>> wrote:
>
>     Rick Waldron wrote:
>
>
>            One way to have it both ways is to have multiple syntactic
>         forms
>            for default value initializers.  EG:
>
>            function f(a = 1, b ??= 2, c ||= 3) { }  //assuming ??= is
>            undefined or null defaulting guard and ||= is falsy
>
>            I'm not particularly convinced that the additional
>         complexity is
>            warranted but it would place the choice into ES programmers
>         hands
>            rather us trying to anticipate the typical intent and
>            disadvantaging the untypical.
>
>
>         I agree with this entirely.
>
>
>     Including the part where Allen is not convinced to add all these
>     forms?
>
>
> Yes.
>
> ...But it felt useful to note that ||= would compliment || and 
> immediately understood by devs
>
>
>     I can see adding ?? and ??= (undefined-only, not undefined-or-null).
>
>
> Yes, absolutely.
>
>
>     Is ||= really worth it? It would not assign if the left side is
>     truthy, but perhaps no one will mind.
>
>
> That makes complete sense to me, but again - it might not be worth 
> adding, because a = b || c isn't that painful.
>
>
>     Given ||= is there any oxygen left in the room for ??=?
>
>
> Right now, I believe the whole set compliment the current language and 
> its operators nicely - but if it came down to one or the other, I 
> would prefer seeing the new addition of ?? and ??=
>
>
> Rick
>
>
>
>     /be
>
>
>         ||= is complementary to || and makes sense - developers will
>         embrace this as is.
>
>
>         ?? and ??= seem like "something is unknown" and unknown things
>         can otherwise be described as "undefined". Definitively,
>         |null| is intentional -- which implies something "known" and
>         therefore cannot qualify as "undefined". I think sticking to
>         undefined will help to fix the abused "== null" patterns in
>         extant code (I'm thinking in the long term of course)
>
>         If null testing is needed:
>
>         a = a != null ? a : default;
>
>
>
>
> _______________________________________________
> 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/20120615/9f93f509/attachment-0001.html>


More information about the es-discuss mailing list