- From: Cameron McCormack <cam@mcc.id.au>
- Date: Sat, 31 Mar 2012 11:13:20 +1100
- To: Boris Zbarsky <bzbarsky@MIT.EDU>
- CC: public-script-coord@w3.org
Boris Zbarsky: > In particular, unions are allowed to contain both a string (or enum) and > a primitive, but if you try to convert a JS value to such a union the > string is always picked (http://dev.w3.org/2006/webapi/WebIDL/#es-union > step 7). That seems wrong. Yes, that's wrong. The intention was to allow void f((float or DOMString) x); to be written because void f(float x); void f(DOMString x); was not allowed, since the two types are not distinguishable. DOMString would be used as the type of last resort, but if a JS Number were passed then it would be converted into the float. I wonder now with the changes we've made to simplify overloading if it's actually useful to have different behaviour between unions and overloads like this. Probably not. So we should either make primitives and DOMString distinguishable for overloading, defaulting to selecting DOMString when there isn't an exact type match like unions were meant to do, or unions shouldn't allow both types. I'm not aware of an API that needs to handle floats and DOMStrings separately -- is there one? If not, we should just disallow it.
Received on Saturday, 31 March 2012 00:13:56 UTC