- From: Allen Wirfs-Brock <allen@wirfs-brock.com>
- Date: Tue, 18 Jun 2013 08:00:38 -0700
- To: Cameron McCormack <cam@mcc.id.au>
- Cc: Brendan Eich <brendan@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Boris Zbarsky <bzbarsky@MIT.EDU>
On Jun 17, 2013, at 11:15 PM, Cameron McCormack wrote: > Boris Zbarsky wrote: >> ES behavior: >> >> 1) Allow specifying a default value for any function argument, even if >> followed or preceded by arguments without default values, with the >> default taking effect if undefined is passed. > > So what about this part of the proposal? Presumably there are reasons that ES6 currently forbids an argument with a default value that is followed by one without a default value. What would be the issue with relaxing this requirement? What's different about rest arguments that allows them (without a default value) to follow an argument with a default value? > > Allen or Brendan? Cameron, Either I'm misinterpreting what you are trying to say or you misunderstand what Boris said. ES6 does allow a parameter with an explicit default value to be followed by one without an explicit default value. The NOTE in 13.1 for ExpectedArgumentCount says: "...A FormalParameter without an initialiser is allowed after the first parameter with an initialiser but such parameters are considered to be optional with undefined as their default value." That semantics is normatively specified in the algorithms that validate a formal parameter list. This is all about determining the "length" value of a function. Length is the number of required arguments which is defined to be the number of formal parameters to the left of the first parameter with a default value initializer (or the rest parameter). Allen >
Received on Tuesday, 18 June 2013 15:01:14 UTC