- From: Jonas Sicking <jonas@sicking.cc>
- Date: Fri, 8 Jun 2012 10:14:53 -0700
- To: Anne van Kesteren <annevk@annevk.nl>
- Cc: Boris Zbarsky <bzbarsky@mit.edu>, public-script-coord@w3.org
On Fri, Jun 8, 2012 at 12:17 AM, Anne van Kesteren <annevk@annevk.nl> wrote: > On Fri, Jun 8, 2012 at 8:46 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote: >> It's not quite clear to me what the right behavior of dictionary member >> default values is. Specifically: >> >> 1) For a dictionary argument, does the implementation actually need to keep >> track of whether a member with a default value was present or not? Or can >> it simply set the member to that default value and treat it as present? >> >> 2) For dictionary return values, what, if anything, should happen with >> default values? Should they end up on the JS object if the relevant member >> was not present in the dictionary? > > I think the default value concept is actually problematic as the > dictionary argument is typically optional. When that is the case you > still need to handle the case for when it is omitted and define the > default values in prose. (I'd be interested in seeing examples of > specifications where this is not the case.) The way I would prefer for it to work is that dictionaries should always be optional arguments. And passing null or undefined as the argument value should be equivalent as passing an empty object. So for interface Foo { func(optional FuncDict params); }; dictionary FuncDict { DOMString x = "val"; }; All of the following should IMHO be equivalent: myFooObj.func(); myFooObj.func(undefined); myFooObj.func(null); myFooObj.func({}); myFooObj.func({x: "val"}); / Jonas
Received on Friday, 8 June 2012 17:15:53 UTC