This is related to what I was trying to figure out in the "more fun with undefined" thread, maybe it is wrong or have too many impact but I was about to suggest :

8.9.1 GetValue (V)
...
5. If IsUnresolvableReference(V), return undefined

11.2.1 Property Accessors
Runtime Semantics: Evaluation
...
3. If baseValue is an abrupt completion or undefined, return baseValue.

Why not, instead of adding "?" operator ?

Le 18/06/2012 07:11, Brendan Eich a écrit :
Sorry, meant to start a new thread for:

http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator

As the Syntax section hints, we can't also adopt CoffeeScript's ?( variant, which enables foo.bar?(args, go, here).baz and the like. The C syntax heritage prevails.

/be

Brendan Eich wrote:
David Herman wrote:
On Jun 15, 2012, at 5:57 PM, satyr wrote:

On Sat, Jun 16, 2012 at 4:33 AM, David Herman <dher...@mozilla.com <mailto:dher...@mozilla.com>> wrote:

    As for null, I can see how there's confusion about whether to use
    null vs undefined, and so I can see why CoffeeScript would just
    try to blur the distinction between them.


Not just for blurring. Rejecting `null` is essential for CoffeeScript's "existence" due to `?.`, the soak/safe access operator.

I think you could make a case for ?. defaulting for both but ?? defaulting only undefined. The case goes something like this:

- The purpose of ?? is to provide a default value when no value was provided. The way to say "no value" in JavaScript is undefined.

- The purpose of ?. is to fail soft when doing a property lookup. Both null and undefined throw when doing a property lookup.

Agreed. This is one choice, it's plausible because of the distinction between defaulting (which requires intentional passing of a "please default" sentinel value, or not passing a trailing actual argument) and soaking up null-or-undefined.

Yes, we could make ?? and ??= do the same for null as for undefined. I'm not sure that's the right choice, but it's a choice. For foo.bar?.baz, though, the clearer choice is to avoid throwing, which means evaluating to undefined if foo.bar is missing (evaluates to undefined) *or* has a value not coercible to object type (null or undefined). See

http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

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

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to