@@isConcatSpreadable

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

@@isConcatSpreadable

Axel Rauschmayer
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
[hidden email]
rauschma.de




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: @@isConcatSpreadable

Tom Schuster
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 <[hidden email]> 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
[hidden email]
rauschma.de




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: @@isConcatSpreadable

Claude Pache
In reply to this post by Axel Rauschmayer

Le 3 juin 2015 à 11:08, Axel Rauschmayer <[hidden email]> a écrit :

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:


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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: @@isConcatSpreadable

Leon Arnott
In reply to this post by Axel Rauschmayer
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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: @@isConcatSpreadable

Claude Pache

> Le 3 juin 2015 à 12:46, Leon Arnott <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: @@isConcatSpreadable

Allen Wirfs-Brock
In reply to this post by Leon Arnott

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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: @@isConcatSpreadable

Herby Vojčík


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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: @@isConcatSpreadable

Brendan Eich-2
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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss