Andy, look at my most recent post to this list. What do you think of that point?
https://mail.mozilla.org/pipermail/es-discuss/2015-October/044337.html On Wed, Oct 7, 2015 at 4:04 AM, Andy Earnshaw <[email protected]> wrote: > Damn, forgot the reply-all button the first time. Including the original > and reply here, plus my reply inline: > > On Tue, 6 Oct 2015 at 19:05 Tab Atkins Jr. <[email protected]> wrote: >> >> On Mon, Oct 5, 2015 at 6:33 AM, Andy Earnshaw <[email protected]> >> wrote: >> > On Sat, 3 Oct 2015 at 00:27 Tab Atkins Jr. <[email protected]> wrote: >> >> A few examples of the ambiguity: >> >> >> >> function f1(...a, b, c) {print arguments} >> >> f1(1) // ([], 1, undefined) or ([], undefined, 1) ? >> >> >> >> function f2(...a, b="default") {print arguments} >> >> f2(1) // ([], 1) or ([1], "default") ? >> >> >> >> function f3(a, b, ...c, d, e) {print arguments) >> >> f3(1,2,3) // (1, 2, [], 3, undefined) or (1, 2, [], undefined, 3) or >> >> (1, undefined, [], 2, 3) or something else? >> > >> > >> > I don't think these are as ambiguous as you say. For the first and >> > third >> > case, the first possible result you mention in both cases seems pretty >> > natural. I don't think you could make an argument for the other cases, >> > they >> > don't really make any sense. >> >> Let me rename the arguments, then, to make it more obvious: >> >> function f1(...frontOfList, secondToLast, last) {print arguments;} >> f1(1) >> // (frontOfList=[], secondToLast=1, last=undefined) >> // or (frontOfList=[], secondToLast=undefined, last=1)? >> >> It would be difficult to argue, given these argument names, that the >> author intended the first result. They clearly intended the second >> result. > > > Function arguments are always filled in from left to right, with the > proposed exception in this case being that rest params don't swallow passed > in arguments when arguments.length <= fn.length. I don't think anyone > coming from a background in writing code would expect the second result, any > more than they would expect: > > function f1 (first, last) { print arguments; } > f1(1); > // (first=undefined, last=1) > > Unless there's a precedent for this behaviour in a language I'm unaware of. > >> >> This is what I mean by: >> >> > You can come up with answers to these questions. What you can't do is >> > come up with answers that are *obviously correct*. >> ~TJ > > > > I don't know... the first result was "obviously correct" to me ;-). > Admittedly, "obviously correct" can be subjective when defining language > behaviour. > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > -- Isiah Meadows _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

