W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

[Bug 23056] Function's length property is inconsistent with EcmaScript

From: <bugzilla@jessica.w3.org>
Date: Wed, 28 Aug 2013 13:22:09 +0000
To: public-script-coord@w3.org
Message-ID: <bug-23056-3890-spN4GsPEGz@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=23056

--- Comment #10 from Erik Arvidsson <arv@chromium.org> ---
This is pretty straightforward to spec in a way that matches ES6 without
resorting to ES6 syntax.

1. Let length be the number of parameters, including optional and rest
parameters.
2. For each parameter of the parameters list, iterating backwards:
   1. If the parameter is an optional parameter, let length be length - 1.
   2. Else if the parameter is a rest parameter, let length be length - 1.
   3. Else return length.
3. Return length.

If there are overloaded operations, return the smallest length.


Boris, ES6 defines undefined to be treated as the sentinel used for no
argument. This is important because a user can pass you undefined as a place
holder.

function f(y = 1) {
  return y;
}
assert(f(undefined) == 1);

function g(x = 1, y = 2) {
  return x + y;
}
assert(g(undefined, 5) == 6);

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Received on Wednesday, 28 August 2013 13:22:10 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC