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 21:56:44 -0500
To: Adam Bergkvist <adam.bergkvist@ericsson.com>, 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: <56CFBEEC.2040609@mozilla.com>
On 2/23/16 2:17 PM, Adam Bergkvist wrote:
> On 2016-02-23 16:30, Jan-Ivar Bruaroey wrote:
>> How about "order"? Not different enough?
> That would be an improvement. Both for the settings dictionary member
> and the readonly attribute.

Great! So lets add:

   enum RTCDataChannelOrder {
     "ordered",
     "unordered"
   };

   dictionary RTCDataChannelInit {
     RTCDataChannelOrder order = "ordered";
     // ...
   };

   interface RTCDataChannel : EventTarget {
     readonly attribute RTCDataChannelOrder order;
     // ...
   };


Then there are no surprises:

   var dc1 = pc.createDataChannel(label, { order: "unordered" });
   var dc2 = pc.createDataChannel(label, { order: "ordered" });
   var dc3 = pc.createDataChannel(label, { order: undefined });
   var dc4 = pc.createDataChannel(label);

   console.log(dc1.order); // unordered
   console.log(dc2.order); // ordered
   console.log(dc3.order); // ordered
   console.log(dc4.order); // ordered


This seems to solve the "avoid having true as default value" problem [1] 
without any downsides.

[1] http://heycam.github.io/webidl/#dfn-dictionary-member-default-value

.: Jan-Ivar :.
Received on Friday, 26 February 2016 02:57:15 UTC

This archive was generated by hypermail 2.3.1 : Friday, 26 February 2016 02:57:16 UTC