Continuing woes in reading the ES6 spec language

Axel Rauschmayer axel at rauschma.de
Sun Sep 15 09:43:14 PDT 2013


> What alternative do you want?
> 
> 1. Parameter default value before default-free parameter means call without arity match throws?
> 
> 2. What Oliver may have feared in switching to named parameters: actual argument list shorter than formal list with default on left causes parameter binding to skip defaults? This is not coherent:
> 
> function foo(x, y = a, z = y) {...}
> 
> foo()        // x=undefined, y=a, z=a
> foo(1)       // x=1, y=a, z=a
> foo(1, 2)    // x=1, y=a, z=2???
> foo(1, 2, 3) // x=1, y=2, z=3
> 
> 3. What ES6 draft says.


The only thing I can see are two, mutually exclusive, modes:

1. Trailing optional positional parameters.
2. Leading optional positional parameters.

There are a few cases, were #2 would be useful. I don’t see other alternatives that make sense. But that may be due to a lack of understand why one would want to have default values in an order that is neither #1 nor #2.

Axel

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130915/a7f4f584/attachment.html>


More information about the es-discuss mailing list