Re: [Bug 23933] Proposal: Change constraints to use WebIDL dictionaries

On 06/12/2013 3:06 AM, Jan-Ivar Bruaroey wrote:
> On 12/6/13 1:10 AM, cowwoc wrote:
>> On 06/12/2013 12:07 AM, Jan-Ivar Bruaroey wrote:
>>> I want to clarify that my proposal does not mandate ignoring 
>>> mandatory constraints, it only allows it. The web developer decides 
>>> whether to fail always (which is basically the default now) or not.
>>
>> How would I tell the browser to throw an error on unknown constraints 
>> if your proposal was implemented?
>
> if (!getGumKnownConstraints().hasOwnProperty("3D")) { throw new 
> Error(); }

That's missing the point, which is that functions should always validate 
their input. If you're going to depend on users to detect their own 
errors you're in for a rude awakening :)

This is similar to the concept of function return values. Exceptions 
were invented to deal with the fact that users neglected checking return 
values for errors and as a result code wouldn't fail-fast. Validating 
input inside the function ensures that it fails-fast, making it easier 
to debug user error.

Gili

Received on Friday, 6 December 2013 16:56:53 UTC