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: Sun, 21 Feb 2016 11:01:16 -0500
To: Peter Thatcher <pthatcher@google.com>, Martin Thomson <martin.thomson@gmail.com>
Cc: Harald Alvestrand <harald@alvestrand.no>, "public-media-capture@w3.org" <public-media-capture@w3.org>
Message-ID: <56C9DF4C.4070604@mozilla.com>
On 2/20/16 2:36 AM, Peter Thatcher wrote:
> On Fri, Feb 19, 2016 at 10:50 PM, Martin Thomson 
> <martin.thomson@gmail.com <mailto:martin.thomson@gmail.com>> wrote:
>
>     On 19 February 2016 at 21:50, Peter Thatcher <pthatcher@google.com
>     <mailto:pthatcher@google.com>> wrote:
>     > But how does converting to an enum help at all?  Wouldn't
>     undefined then
>     > just get turned into an enum value, which is truthy?
>
>     An enum ensures that all valid values that are equally truthy, so
>     truthy/falsy becomes irrelevant.  Yes, the default is truthy, but so
>     is every valid value.
>
> ‚Äč
> So pc.createDataChannel("label", {ordered: undefined}) is still going 
> to be ordered, right?

Right.

> So how are we better off with an enum in this case?

Because there's precedent for expecting undefined to be interpreted as 
false [1], and no such precedent for strings?

>     > And if a truthy value of a default is discouraged, then are the only
>     > encouraged defaults the falsy ones (false/null/""/0/NaN)?
>
>     This is only relevant for dictionary parameters with Boolean types.
>

[1] https://developer.mozilla.org/en-US/docs/Glossary/Falsy

.: Jan-Ivar :.
Received on Sunday, 21 February 2016 16:01:46 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 21 February 2016 16:01:47 UTC