- From: Eric Rescorla <ekr@rtfm.com>
- Date: Wed, 11 Dec 2013 13:43:01 +0800
- To: Harald Alvestrand <harald@alvestrand.no>
- Cc: "public-media-capture@w3.org" <public-media-capture@w3.org>
On Tue, Dec 10, 2013 at 11:00 PM, Harald Alvestrand <harald@alvestrand.no> wrote: > On 12/09/2013 06:03 PM, Martin Thomson wrote: >> >> Regarding the use of dictionaries for constraints, specifically >> mandatory constraints. Here's where I think that the status of the >> debate is at: >> >> Jan-Ivar doesn't want to use something that looks like a dictionary, but >> isn't. >> >> Harald and Gili are certain that they want a particular behaviour. >> >> (I don't believe that we are completely agreed that mandatory is a >> good idea, but let's pretend that it is.) >> >> I think that though the arguments are frequently misleading, both >> groups are fundamentally right. They don't want strictly opposing >> things. So let me propose a solution. >> >> var c = new ConstraintSet(); >> c.set('width', 1280); >> c.set('height', 720); >> navigator.getUserMedia({ audio: true, video: { mandatory: c } }, >> successCb, failureCb); >> >> Done. >> >> The idea that a dictionary is appropriate here is, at best, a stretch. >> Don't look at every problem and assume that your hammer will work. A >> dictionary is not appropriate for this use case, and pretending that >> it is does no favours to anyone. > > > I find dictionaries an interesting concept, among other things because they > don't really exist in Javascript. > > A dictionary is defined to have an automatic conversion from a Javascript > object to a dictionary - but that conversion is allowed to lose information, > and we want some of the information that transformation is going to lose. > > I'd like to preserve two properties of our current spec: > > - That we can get an error on unsupported constraint names > - That we can get automatic conversion from objects specified in Javascript > as { name : value } > > As long as I get those two properties, I don't care what the name of the > construct is. > > The "dictionary" proposal loses the first property. > The "c.set" proposal loses the second property (but is able to recreate it > with a Small Amount of Polyfill). I agree with Harald here. If the only relevant property of ConstraintsSets is that they have key-val pairs, it makes sense in JS to model that as a dictionary, and indeed this is a common JS idiom. -Ekr
Received on Wednesday, 11 December 2013 05:44:09 UTC