W3C home > Mailing lists > Public > public-media-capture@w3.org > February 2016

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

From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Thu, 25 Feb 2016 14:21:43 -0500
To: Peter Thatcher <pthatcher@google.com>
Cc: Martin Thomson <martin.thomson@gmail.com>, Harald Alvestrand <harald@alvestrand.no>, "public-media-capture@w3.org" <public-media-capture@w3.org>
Message-ID: <56CF5446.3030204@mozilla.com>
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

This archive was generated by hypermail 2.3.1 : Thursday, 25 February 2016 19:22:15 UTC