See below: I'm not sure who told Cameron that this is likely to change from the current spec. but regardless I don't think it is a good idea.
Just to start, it means a method like: Array.prototype.fill = function(value=null) { this.forEach((v,i)=>this[i]=value)} wouldn't do the obvious thing when called as: someArray.fill(undefined) Allen Begin forwarded message: > Resent-From: public-script-co...@w3.org > From: Cameron McCormack <c...@mcc.id.au> > Date: April 11, 2012 5:15:35 PM PDT > To: "public-script-co...@w3.org" <public-script-co...@w3.org> > Cc: Jonas Sicking <jo...@sicking.cc>, Brendan Eich <bren...@mozilla.com>, > David Herman <dher...@mozilla.com>, Sam Tobin-Hochstadt <sa...@ccs.neu.edu> > Subject: undefined being treated as a missing optional argument > > A few months ago we had some long discussions about what it means to pass > undefined as the value of an optional argument, for example: > > void f(optional long x); > > called with: > > f(undefined); > > What we eventually settled on was that an explicit undefined is always > treated as a specified argument, so for the above case undefined would be > converted to the IDL long value 0. Here's where the original decision was > announced: > > http://www.w3.org/mid/4ef3db9c.4080...@mcc.id.au > > Maybe the strongest reason for deciding this way was to align with how ES6 > was going to handle function argument default values. It's been brought to > my attention though that this behaviour is not yet fixed for ES6 and there's > a good possibility that ES6 will specify that passing undefined will cause > the argument's default value to be used. If that happens, then it seems like > we might again want Web IDL to change to be consistent with that. > > Unless there are any objections, I'm going to add a note to the spec to point > out that undefined is currently not treated as a missing optional argument in > alignment with ES6, but that ES6 may yet change and that we might revisit the > decision at that point. > > (If we did revisit the decision, there are various knock-on changes we'd need > to make (again) such as bringing dictionaries in line by having an undefined > value specified for a dictionary member mean that it is not present, ensuring > that the overload resolution algorithm can handle this, deciding what it > means to pass undefined to an optional argument of IDL type any, and so on.) >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss