On Sep 27, 2012, at 10:09 AM, Jason Orendorff wrote: > On Thu, Sep 27, 2012 at 11:19 AM, Allen Wirfs-Brock > <[email protected]> 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; > }
Yes, essentially that plus presumably appropriate length checks on %args. Also, I assume by "arguments" you mean the actual passed argument vector rather than the arguments object. Allen _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

