Default operator strawman - ||| rather than ??
dherman at mozilla.com
Wed Jun 13 10:58:32 PDT 2012
On Jun 12, 2012, at 11:44 PM, Thaddee Tyl wrote:
> Besides, it often has a similar meaning: I have seen in a lot of code
> a de-facto standard wherein null is used to indicate a value that is
> voluntarily undefined. You can see this pattern all over node.js code,
> for instance.
I *think* this is the key point, but I'm still trying to figure out the implications.
I believe you're right, and I think it calls into question the "undefined means no-value, null means no-object" mantra. In practice, I think it's really "undefined means uninitialized, null means no-value."
> Harmony's default parameters will make this easier, while letting a
> null value through -- which will make this pattern even more common.
This confuses me. If default parameters *don't* treat null as requiring a default, won't that work against this pattern?
> Besides, the null value can be obtained from the standard library,
> when calling certain methods.
> Object.getPrototypeOf(...), string.match(...), even calling the toJSON
> method of a Date can return null.
> Having a way to deal with those return values by providing a default
> value would be nice.
That's a pretty strong argument IMO.
Dave, still mulling
More information about the es-discuss