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: Peter Thatcher <pthatcher@google.com>
Date: Fri, 19 Feb 2016 21:50:31 -0800
Message-ID: <CAJrXDUHiDRam+LvAX8YLd=2PHk_ge2hbYS+gfJLKfH+Yt6Xb1Q@mail.gmail.com>
To: Martin Thomson <martin.thomson@gmail.com>
Cc: Jan-Ivar Bruaroey <jib@mozilla.com>, Harald Alvestrand <harald@alvestrand.no>, "public-media-capture@w3.org" <public-media-capture@w3.org>
But how does converting to an enum help at all?   Wouldn't undefined then
just get turned into an enum value, which is truthy?

And if a truthy value of a default is discouraged, then are the only
encouraged defaults the falsy ones (false/null/""/0/NaN)?




On Fri, Feb 19, 2016 at 4:51 PM, Martin Thomson <martin.thomson@gmail.com>
wrote:

> On 17 February 2016 at 19:50, Jan-Ivar Bruaroey <jib@mozilla.com> wrote:
> > So the only difference here would appear to be mental: In that,
> undefined,
> > being falsy, is arguably a valid input to a boolean, i.e. users might
> > reasonably expect undefined to produce false, not true, and they would be
> > right.
>
>
> The problem is when you have:
>
> dictionary Foo {
>   boolean bar = true;
> };
>
> That is the discouraged pattern.  Because undefined is converted to
> true in direct violation of the usual truthy/falsy conversions
> pattern.
>
Received on Saturday, 20 February 2016 05:51:44 UTC

This archive was generated by hypermail 2.3.1 : Saturday, 20 February 2016 05:51:45 UTC