- From: liorean <liorean@gmail.com>
- Date: Fri, 11 Apr 2008 05:17:08 +0200
- To: "Web APIs WG (public)" <public-webapi@w3.org>
On 11/04/2008, Ian Hickson <ian@hixie.ch> wrote: > It would be nice for the spec to explicitly say how to handle argument > calls that have not enough arguments, both for normal methods and for > overloaded methods. (The right answer probably being whatever IE does.) ECMA-262 3ed has this to say about how this works in ES functions: ----<10.1.3 Variable Instantiation >--- • For function code: for each formal parameter, as defined in the FormalParameterList, create a property of the variable object whose name is the Identifier and whose attributes are determined by the type of code. The values of the parameters are supplied by the caller as arguments to [[Call]]. If the caller supplies fewer parameter values than there are formal parameters, the extra formal parameters have value undefined. If two or more formal parameters share the same name, hence the same property, the corresponding property is given the value that was supplied for the last parameter with this name. If the value of this last parameter was not supplied by the caller, the value of the corresponding property is undefined. ----</>---- The result of applying that behaviour to DOM methods would be that a call with too few arguments is handled as if the missing arguments were filled in with ECMAScript undefined, which would cause a TYPE_MISMATCH_ERR exception to be thrown (unless the DOM interface explicitly allows Undefined I guess...). Is that a reasonable behaviour for the DOM as well? -- David "liorean" Andersson
Received on Friday, 11 April 2008 03:24:50 UTC