W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Worry on Enum type - binding seems inconsistently defined

From: Harald Alvestrand <harald@alvestrand.no>
Date: Tue, 10 Jan 2012 10:17:40 +0100
Message-ID: <4F0C0234.9040203@alvestrand.no>
To: "WebApps WG (public-webapps@w3.org)" <public-webapps@w3.org>
Hello,

the WebRTC WG is currently contemplating following the WebApps WG's 
advice on avoiding use of integers in APIs, and switching to enums 
whenever possible.
However, one detail makes the spec at this time a bit hard to 
understand: In section 3.5, the following is said:

Note

In the ECMAScript binding, assignment of an invalid string value to 
anattribute <http://dev.w3.org/2006/webapi/WebIDL/#dfn-attribute>is 
ignored, while passing such a value as anoperation 
<http://dev.w3.org/2006/webapi/WebIDL/#dfn-operation>argument results in 
an exception being thrown.

However, in the ECMAScript binding, section 4.2.18, it says:


An ECMAScript value V is converted to an IDL enumeration type value as 
follows (where E is the enumeration):

1. Let S be the result of calling ToString(V).
2. If S is not one of E's enumeration values, then throw a TypeError.
3. Return the enumeration value of type E that is equal to S.

I'm not sure it says the same thing; more clarity on the expected 
behaviour would be useful.
(My personal opinion is that it's most useful if assigment throws an 
exception; silent failure is rarely the best option.)

Although other bindings don't really matter so much, I would also think 
that it was a Good Thing if the spec gave advice saying that all 
bindings should detect value errors at assignment time, and signal 
errors appropriately for that language, rather than leaving the decision 
to binding designers.

That's all my worry....

             Harald
Received on Tuesday, 10 January 2012 09:18:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:49 GMT