"Exception: parameter(s) with default followed by parameter without default"

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Oct 10 09:12:44 PDT 2012


On Oct 10, 2012, at 6:39 AM, David Bruant wrote:

> 2012/10/10 Keith Cirkel <es-discuss at keithcirkel.co.uk>
> You /are/ actually passing in a second argument though, your second argument is `undefined`. Default arguments aren't meant to replace `undefined` values, they're meant to be permissible for omission.


No, that isn't what the draft specification now says.  It was originally that way, but TC39 based upon discussions here, decided that an explicit undefined argument value triggers default value initialization.

> 
> From https://bugzilla.mozilla.org/show_bug.cgi?id=781422#c1 
>     function f(x=EXPR) { BODY }
> will expand to:
>     function f(x) {
>         if (x === undefined)
>             x = EXPR;
>         BODY
>     }
> 
> It seems that default arguments are meant to replace 'undefined' for last arguments and that's my experience playing with the latest nightly where the bug has been fixed.
> 
> What's the intention of the spec?
> Is current Firefox Nightly compliant?

no

> Can test262 tests be added to express what is expected from implementors? Debating tests would enable keeping track of the discussions that occurred and record the decision in an (arguably) more formal way than the spec.

Yes, if a contributor writes them. But the starting point for the tests need to be what the specification actually says.

Allen



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


More information about the es-discuss mailing list