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

Re: Reconciling handling of optional arguments and handling of default values across ES and webidl

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Tue, 18 Jun 2013 08:03:25 -0700
Cc: Cameron McCormack <cam@mcc.id.au>, Brendan Eich <brendan@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-Id: <5B6F62AF-C6CE-4CC4-8C4C-7401788655F1@wirfs-brock.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>

On Jun 18, 2013, at 5:24 AM, Boris Zbarsky wrote:

> On 6/18/13 2:15 AM, Cameron McCormack wrote:
>> 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.
> 
> The reason I was given is that given
> 
>  function f(a = 5, b) {
>  }
>  f(6);
> 
> it's not clear whether that maps to (a=6,b=undefined) or to (a=5,b=6).
> 
> That said it's pretty clear to me that it maps to the former.  On the other hand, it sure would be handy to be able to do f(undefined, 6) and have it come out with (a=5,b=6).


The former is what ES6 specifies. Arguments are mapped to formal parameters left to right without considering whether or not a a default value initializer is present. 








> 
> -Boris
> 
Received on Tuesday, 18 June 2013 15:04:04 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:13 UTC