Array tail destructuring

Olivier Lalonde olalonde at gmail.com
Sat Oct 1 19:29:14 UTC 2016


> ```
> function* ones(){ while(true) yield 1; }
> var [...a]=ones(); // freezes
> ```

So if that freezes, whats the problem with `[...a, last]`? It would just
freeze as well...

> access to array elements may have side effects

Doesn't `[a, b,...vals]` access array elements?


On Sat, Oct 1, 2016 at 10:29 AM, Cyril Auburtin <cyril.auburtin at gmail.com>
wrote:

> ah ok, I forgot about other types of iterables, like infinite ones:
> ```
> function* ones(){ while(true) yield 1; }
> var [...a]=ones(); // freezes
> ```
>
>
> 2016-10-01 18:24 GMT+02:00 Dmitry Soshnikov <dmitry.soshnikov at gmail.com>:
>
>> Yeah, because it's not a pattern patching, and access to array elements
>> may have side effects, it's seems hard to specify/implement. Otherwise,
>> destructuring might analyze the pattern, see the last element is required,
>> extract it, and then do iteration for others.
>>
>> Dmitry
>>
>>
>> On Saturday, October 1, 2016, Michael Theriot <
>> michael.lee.theriot at gmail.com> wrote:
>>
>>> I think this is because there's no universal way of determining when an
>>> iterator ends. The only way this could work for all iterators would require
>>> popping values off of `a` after they've been added.
>>>
>>> On Sat, Oct 1, 2016 at 6:17 AM, Cyril Auburtin <cyril.auburtin at gmail.com
>>> > wrote:
>>>
>>>> It was possibly already discussed, but why isn't:
>>>> ```
>>>> var [...a, last] = [1,2,3];
>>>> ```
>>>> supported?
>>>>
>>>> I don't see the problem, as long as there's one ... only
>>>>
>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> es-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>>>
>>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
- Oli

Oli Lalonde
http://www.syskall.com <-- connect with me!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161001/d6459f0f/attachment.html>


More information about the es-discuss mailing list