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

[WebIDL] Worry on Enum type - binding seems inconsistently defined

From: Arthur Barstow <art.barstow@nokia.com>
Date: Wed, 11 Jan 2012 17:41:01 -0500
Message-ID: <4F0E0FFD.4020509@nokia.com>
To: Cameron McCormack <cam@mcc.id.au>, public-script-coord <public-script-coord@w3.org>
CC: Harald Alvestrand <harald@alvestrand.no>
Hi Cameron, All - would you please respond to the question below about 
Web IDL? -Thanks, AB

-------- Original Message --------
Subject: 	Worry on Enum type - binding seems inconsistently defined
Resent-Date: 	Tue, 10 Jan 2012 09:18:18 +0000
Resent-From: 	<public-webapps@w3.org>
Date: 	Tue, 10 Jan 2012 10:17:40 +0100
From: 	ext Harald Alvestrand <harald@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 Es 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 Wednesday, 11 January 2012 22:41:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC