- From: Kyle Huey <me@kylehuey.com>
- Date: Fri, 29 Jun 2012 09:37:13 -0700
- To: Joshua Bell <jsbell@chromium.org>
- Cc: public-webapps@w3.org
- Message-ID: <CAP045Ap3-2vkVaY=H4xqSk7ptUnGGnmde-7KS1qzTcaLWz=ycg@mail.gmail.com>
On Fri, Jun 29, 2012 at 9:25 AM, Joshua Bell <jsbell@chromium.org> wrote: > Over in WebKit-land there's some disagreement about WebIDL method overload > resolution, specifically around passing null, arrays (T[]) and the concept > of Nullable. > > Here's an example where we're just not sure what the WebIDL spec dictates: > > void f(float[] x); // overload A > void f(DOMString x); // overload B > > WebIDL itself, of course, doesn't dictate how matching and dispatching > should be implemented; it instead defines whether types are > distinguishable. The implication is that an IDL that defines methods with > signatures that are not distinguishable is invalid, so it's a non-issue in > terms of the spec. So rephrasing the question: are the above types > distinguishable? And if so, which would be expected to handle the call: > > f(null); > > Several interpretations and hence outcomes occur to us, hopefully > presented without indicating my particular bias: > > (1) T[] is inherently Nullable (i.e. T[] === T[]?), DOMString is not, > overload A would be invoked with a null argument and the implementation is > expected to handle this case > (2) T[] accepts null but the IDL type to ECMAScript conversion rules > produce an empty array; overload A is invoked with an empty float array > (3) T[] does not match null, but as null is an ECMAScript primitive value > it is run through ToString() and hence overload B is invoked with DOMString > "null" > (4) Either T[] or DOMString could match null, so types of the arguments > are not distinguishable and hence the above is invalid WebIDL > (5) Neither T[] nor DOMString is inherently Nullable, so a TypeError is > thrown > > Anyone? (Cameron?) > #5. Neither T[] nor DOMString admits null as a value. "Note also that null is not a value of type DOMString. To allow null, a nullable DOMString, written as DOMString? in IDL, needs to be used. " http://dev.w3.org/2006/webapi/WebIDL/#idl-DOMString "The T[] type is a parameterized type. The values of this type are non-null references to arrays of values of type T." http://dev.w3.org/2006/webapi/WebIDL/#idl-array - Kyle
Received on Friday, 29 June 2012 16:37:42 UTC