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

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