Re: Using enums to avoid default true in "settings dictionaries" (#466, #467, #471)

On 2/24/16 11:10 AM, Peter Thatcher wrote:
> On Tue, Feb 23, 2016 at 10:48 PM, Jan-Ivar Bruaroey <jib@mozilla.com 
> <mailto:jib@mozilla.com>> wrote:
>
>     function foo(bar, baz) {
>       return baz ? bar : null;
>     }
>
>     foo("bar") // null
>     foo("bar", false)  // null
>     foo(1, undefined)  // null
>     foo(1, false)  // null
>
>
> ​Do you really think all of the Javascript in the world uses booleans 
> "correctly"?

That's a straw man argument. Boolean is well-defined in both JavaScript 
[1] and WebIDL [2].

> The assertion that foo("bar") == for("bar", false) in all cases is 
> false.  A developer can't rely on it, and shouldn't rely on it.

Again, a straw man. It doesn't have to be true in all cases to be a 
common pattern.

> ​
> I don't think we should make our API worse to
> ​ trying to maintain this false expectation.
>
> ​If we can come up with a strong argument for making our API worse, 
> I'm willing to hear it.  But I'm not convinced by this one.

FWIW, I think we need a strong argument to disregard an explicit warning 
in WebIDL [3], and I haven't heard one.

[1] https://tc39.github.io/ecma262/#sec-toboolean
[2] https://heycam.github.io/webidl/#es-boolean
[3] https://heycam.github.io/webidl/#dfn-dictionary-member-default-value

.: Jan-Ivar :.

Received on Thursday, 25 February 2016 19:22:14 UTC