Default argument values

Steven Mascaro subs at voracity.org
Sun Mar 2 15:59:43 PST 2008


One last issue. I was going to leave it till later, but I realised it
may affect ES4.

The nicest syntax for named arguments would be to use ':', just like
with object literals. e.g.:

/// Define
function foo(arg1 = 0, arg2 = 1) { ... }

/// Call
foo(arg2: 10, arg1: 5);

(I find this even more attractive than the Python syntax.) But this
could potentially conflict with the type annotation syntax. e.g.:

/// Call
foo(arg1: ClassA, arg2);

At the moment, the RI throws a ParseError for that, so there's no
conflict. I'd like to request that this syntax be reserved solely for
named arguments.



More information about the Es4-discuss mailing list