jashkenas/coffee-script — pull request #3268 by xixixao (2013-12-01 04:58:31+00:00)
Title: Implement #156, Added expansion to destructuring

This isn't a finalized PR, I would like to know if we want something like this before putting more time into it:

Implements #156 (oldest open issue currently). Namely @epidemian's [proposal](https://github.com/jashkenas/coffee-script/issues/156#issuecomment-17941507).
```coffee
[first, middle..., last] = array # works today
[first, .., last] = array # works with this PR

[.., last] = ratherLongVariableName
last = ratherLongVariableName[ratherLongVariableName.length - 1] # rather long
[.., last] = a
last = a[a.length - 1] # still longer, repetitive
```
This matches nicely the ability of taking first `n` elements out of an array.

What's left: check that using expansion(**..**) outside of pattern matching raises correct error (and possibly call it something better). Pick out the simple case (only one assignee after expansion) and stream line the compiled JS.

Also, for those with limited number of keystrokes, we could switch to `[first, second..last] = array`, but this syntax is too similar to ranges so someone else would have to pick this up and change the grammar accordingly (it is really hard when using a bottom-up parser generator and not being the original author to avoid conflicts).

Thoughts?