Re: Unclear behavior of dictionary member default values

On 6/8/12 3:37 AM, Anne van Kesteren wrote:
> On Fri, Jun 8, 2012 at 9:25 AM, Boris Zbarsky<bzbarsky@mit.edu>  wrote:
>> If the question was what specs use default values on dictionaries... WebGL
>> does for the WebGLContextAttributes dictionary.
>
> The problem I was pointing out is prevalent there. It appears the
> WebGLContextAttributes dictionary is passed as second argument to the
> getContext() method. That argument is optional.

Ah, you were talking about the whole dictionary being optional!  OK.

Are there use cases for having an API where passing an empty dictionary 
and not passing a dictionary at all have different behavior?  If not, it 
might be nice if WebIDL just handled this so you could actually usefully 
declare the whole thing in IDL instead of having to do it in prose...

> They solve this using some prose "The default value is used either if
> no second parameter is passed to getContext, or if a user object is
> passed which has no attribute of the given name." but that seems
> hacky.

Could we move that sort of language into WebIDL?  ;)

-Boris

Received on Friday, 8 June 2012 14:05:47 UTC