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

Re: [WebIDL] Allowing specifications to opt in to throwing on sets of enumerated attributes to invalid values

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 15 Nov 2012 07:09:21 -0800
Message-ID: <50A505A1.4090106@mit.edu>
To: Marcos Caceres <w3c@marcosc.com>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
On 11/15/12 3:59 AM, Marcos Caceres wrote:
> This sounds ok to me, but did you have any particular cases in mind?

Yes, WebAudio would sort of like to use IDL enums but not have the 
silently-do-nothing behavior.  Right now they're using integer constants 
instead, because those allow them to throw from inside the setter on 
invalid values.  :(

> The only concern I have is that it could affect compatibility in that it kinda introduces versioning (and then need to then wrap all code in try/catch blocks).

Well... so the thing is that the cases that need try/catch blocks are 
the cases that would silently fail to work at all otherwise, right?  The 
current "silently ignore" behavior makes sense for cases when there is a 
sensible fallback value which is already preset, but really doesn't make 
sense in the WebAudio situation from what I understand.

> Worst case, you end up with something like:
> try{
> fooObj.bar = value;
> //did it really assign the value?
> if(fooObj.bar === value){

Why do you need that if check?  The whole point of [strict] is that if 
it didn't throw, it assigned the value.

Received on Thursday, 15 November 2012 15:09:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:07 UTC