Re: Dictionary-shaped Hammers

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).

>
> For backwards compatibility we can use a union type, and we can revert
> to incompatible behaviour if that is chosen.  I'd chose the ignore
> unknown here, but add a deprecation warning so that people encouraged
> not to cause harm to themselves and others.
>
> I think at the point that people from competing browsers are telling
> the other that their implementation is wrong, we've lost the plot.
> Let's not go there.
>

Received on Tuesday, 10 December 2013 15:00:47 UTC