Re: @@isConcatSpreadable
Allen Wirfs-Brock wrote: On Jun 3, 2015, at 3:46 AM, Leon Arnott wrote: This reminds me: I feel like the spec should've added Array.prototype[Symbol.isConcatSpreadable] (value:true, configurable:false, writable:false), and eliminated the final IsArray() test from [22.1.3.11](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconcatspreadable). Would've made the Array#concat() behaviour a little cleaner, in my opinion. Unless, perhaps, the point was to leave it open and allow the end-user to monkey-patch it to false, thus finally fixing Array#concat() after all these years...? Was that the plan? Exactly! ES6 has to preserve the previous semantics for all existing programs, including programs that attempted to create Array subclasses in various ad hoc manners. @@isConcatSpreadable exists to allow new ES6-level array subclasses to explicitly opt-out of the legacy implicit spread behavior of concat. So when one actually _wants_ to concat (as, add elements of the iterable), it should stop using concat for that and must do something like var concatenated = first.slice(); concatenated.push(...second, ...third, ...fourth); ? Allen Herby ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: @@isConcatSpreadable
Herby Vojčík wrote: So when one actually _wants_ to concat (as, add elements of the iterable), it should stop using concat for that and must do something like var concatenated = first.slice(); concatenated.push(...second, ...third, ...fourth); Or use concat but wrap the parameter with []. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: @@isConcatSpreadable
It's meant as an extension point. I believe some DOM list/array is supposed to use this. On Wed, Jun 3, 2015 at 11:08 AM, Axel Rauschmayer a...@rauschma.de wrote: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.concat I’m not seeing @@isConcatSpreadable being used as a property key anywhere in the spec. Thanks! Axel -- Dr. Axel Rauschmayer a...@rauschma.de rauschma.de ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: @@isConcatSpreadable
Le 3 juin 2015 à 11:08, Axel Rauschmayer a...@rauschma.de a écrit : https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.concat https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.concat I’m not seeing @@isConcatSpreadable being used as a property key anywhere in the spec. Thanks! Axel Look at the IsConcatSpreadable abstract operation: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconcatspreadable Note that, in absence of @@isConcatSpreadable property key, IsArray() is considered instead, so that builtin objects and constructors defined in the spec do not need to use @@isConcatSpreadable in order to get the right semantics. —Claude___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Re: @@isConcatSpreadable
This reminds me: I feel like the spec should've added Array.prototype[Symbol.isConcatSpreadable] (value:true, configurable:false, writable:false), and eliminated the final IsArray() test from [22.1.3.11](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconcatspreadable). Would've made the Array#concat() behaviour a little cleaner, in my opinion. Unless, perhaps, the point was to leave it open and allow the end-user to monkey-patch it to false, thus finally fixing Array#concat() after all these years...? Was that the plan? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: @@isConcatSpreadable
Le 3 juin 2015 à 12:46, Leon Arnott leonarn...@gmail.com a écrit : This reminds me: I feel like the spec should've added Array.prototype[Symbol.isConcatSpreadable] (value:true, configurable:false, writable:false), and eliminated the final IsArray() test from [22.1.3.11](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconcatspreadable). Would've made the Array#concat() behaviour a little cleaner, in my opinion. Given that inheriting from `Array.prototype` and being an Array object are two distinct notions, that would be a breaking change from the past that needs careful consideration. —Claude ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: @@isConcatSpreadable
On Jun 3, 2015, at 3:46 AM, Leon Arnott wrote: This reminds me: I feel like the spec should've added Array.prototype[Symbol.isConcatSpreadable] (value:true, configurable:false, writable:false), and eliminated the final IsArray() test from [22.1.3.11](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconcatspreadable). Would've made the Array#concat() behaviour a little cleaner, in my opinion. Unless, perhaps, the point was to leave it open and allow the end-user to monkey-patch it to false, thus finally fixing Array#concat() after all these years...? Was that the plan? Exactly! ES6 has to preserve the previous semantics for all existing programs, including programs that attempted to create Array subclasses in various ad hoc manners. @@isConcatSpreadable exists to allow new ES6-level array subclasses to explicitly opt-out of the legacy implicit spread behavior of concat. Allen. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss