- From: Boris Zbarsky <bzbarsky@mit.edu>
- Date: Tue, 1 Dec 2015 10:43:45 -0500
- To: Harald Alvestrand <harald@alvestrand.no>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 12/1/15 9:56 AM, Harald Alvestrand wrote: > But the table at http://heycam.github.io/webidl/#idl-overloading says > that dictionary, callback functions and objects aren't distinguishable > from each other. > > Can someone point me to an explanation of why? Historically, because IDL aimed to not make things distinguishable that might be hard to distinguish. In particular, any object can really be used as a dictionary. JS Functions are objects. If a Function is passed to an overload of dictionary and callback function, which one should it be used for? It's even worse for the generic "object", which is literally "any object at all". That said, I think we could, in fact, make callback functions and dictionaries distinguishable. It wouldn't even require any changes to the overload resolution algorithm, as far as I can tell: http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm step 12 already checks IsCallable(V), so we would end up with overloads between dictionary and callback function distinguished by what IsCallable() returns. Dictionaries would still not be distinguishable from callback _interfaces_, of course, and none of this stuff would be distinguishable from "object". That said, what is the actual use case here? If this is a new API, you should probably just use a dictionary and not create the two overloads. -Boris
Received on Tuesday, 1 December 2015 15:44:17 UTC