Allow overload resolution to "round down"? · Issue #581 · whatwg/webidl (original) (raw)
In simplifying document.open() (see whatwg/html#3946) we would ideally like to have two overloads:
partial interface Document { [CEReactions] Document open(); WindowProxy open(USVString url, DOMString name, DOMString features); }
However, according to the overload resolution algorithm, if we did this, calls to document.open("historical", "historical")
would throw pretty quickly:
- Effective overload set = { open(), open(url, name, features) }
- Let maxarg be the length of the longest type list of the entries in S = 3.
- Let n be the size of args = 2.
- Initialize argcount to be min(maxarg, n) = 2.
- Remove from S all entries whose type list is not of length argcount. S = empty set
- If S is empty, then throw a TypeError.
Would it be possible to tweak this to allow ignoring extra arguments? That seems more JavaScriptey to me...
Pointers to previous discussions appreciated.