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

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.

-Boris

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