Handling too few arguments in method calls

From some very brief testing, it seems that Firefox and Opera tend
to throw an exception when calling a method with too few arguments,
while IE, Safari and Chrome will assume that the missing arguments were
the undefined value.  Extra arguments tend to be ignored.

Does anyone have an opinion on which way this should be specified in Web
IDL?  Assuming this interface:

  interface A {
    /* f1 */ void f(in DOMString a);
    /* f2 */ void f(in DOMString a, in float b);
    /* f3 */ void f(in DOMString a, in float b, in float c, in float d);
  };

option 1 would be to have:

  a.f() be like calling f1 with (undefined)
  a.f('a') be like calling f1 with ('a')
  a.f('a', 1) be like calling f2 with ('a', 1)
  a.f('a', 2, 3) be like calling f3 with ('a', 2, 3, undefined)
  a.f('a', 2, 3, 4, 5) be like calling f3 with ('a', 2, 3, 4)

and option 2 would be to have:

  a.f() throw an exception
  a.f('a') be like calling f1 with ('a')
  a.f('a', 1) be like calling f2 with ('a', 1)
  a.f('a', 2, 3) throw an exception
  a.f('a', 2, 3, 4, 5) be like calling f3 with ('a', 2, 3, 4)

Web IDL currently says to throw on any incorrect number of arguments,
so it seems that it should change to be one of the above two options.

Thanks,

Cameron

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Monday, 22 June 2009 00:54:13 UTC