>>> Just to start with, what does this mean: >>> >>> [a,b,...r,c,d = [1,2,3] >> >> That seems related to >> [a, b, c, d] = [1,2,3] >> and to >> [a,b,...r,c,d] = [1,2,3,4] >> >> Hence, I would guess: >> a === 1 >> b === 2 >> r === [] >> c === 3 >> d === undefined > > Why guess?
I’m not sure I understand. > There is no requirement that ...r consume 1 element, It consumes 0 elements above. > but there is a requirement in Dave's desugaring that trailing non-rest > element patterns consume elements up to the one indexed by rhs.length - 1. But that doesn’t help if there are more trailing elements in the pattern than in the array to be destructured. My definition would be: [a1, ⋯ , an, ...r, b1, ⋯, bm] = [c1, ⋯, cl] - n+m > l: r is bound to [], the non-rest pattern variables are bound as if there was no rest element: [a1, ⋯ , an, b1, ⋯, bm] = [c1, ⋯, cl] - Otherwise r is bound to an array [r1, ⋯, rk] (with k = l-(n+m)) whose elements are determined via [a1, ⋯ , an, r1, ⋯, rk, b1, ⋯, bm] = [c1, ⋯, cl] -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss