repeated parameter names and default values

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Sep 27 10:18:58 PDT 2012


as described here

function f(a) {
  // var a superflous ... still works
  var a, b = a, a = 3, c = a;
  return a+" "+b+" "+c;
}

same / equivalent result

On Thu, Sep 27, 2012 at 6:09 PM, Jason Orendorff
<jason.orendorff at gmail.com>wrote:

> On Thu, Sep 27, 2012 at 11:19 AM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
> >    function f(a, b=a, a=3, c=a) {
> >       return a+" "+b+" "+c
> >    }
> >    console.log(f(1));
> >
> > Based upon the conclusions about argument binding at the recent TC39
> meeting this will display:
> >   "3 1 3"
>
> Not having been at the meeting, I had a little trouble coming up with
> a desugaring where this worked. Is this the idea?
>
>     function f(a, b, a, c) {
>         var %args = a copy of arguments;
>         a = %args[0];
>         b = %args[1] === void 0 ? a : %args[1];
>         a = %args[2] === void 0 ? 3 : %args[2];
>         c = %args[3] === void 0 ? a : %args[3];
>         return a+" "+b+" "+c;
>     }
>
> (Of course I understand it won't be specified in terms of desugaring
> but through changes to 10.5.3, "Function Declaration Instantiation").
>
> For what it’s worth, I’m with David and Oliver: by all means, just
> make that a SyntaxError.
>
> -j
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120927/6bb7118f/attachment.html>


More information about the es-discuss mailing list