Re: ArrayClass should imply @@isConcatSpreadable

* Allen Wirfs-Brock wrote:
>On Oct 28, 2013, at 5:52 PM, Domenic Denicola wrote:
>
>> From: Allen Wirfs-Brock [mailto:allen@wirfs-brock.com]
>> 
>>> So what's so onerous about returning a fresh array from the getter each time it was called.
>> 
>> The fact that `api.property !== api.property`.
>
>You mean people want to do identity checks of the value of the property? Why?

It might be helpful to look at it the other way around. If you spend a
day chasing down a bug that boils down to the problem above triggered in
some subtle way, would you say that the issue should have been caught in
code review and there should have been tests for issues like this? Would
you say it's safe to change a popular API from returning the same object
to returning a different object every time?

It is not diffcult to end up with code that does something like this:

  var temp = a.example;
  ...
  if (...) {
    ...
    temp = b.example;
  }
  ...
  if (temp === a.example) {
    ...
  } else /* temp === b.example */ {
    ...
  }

which works fine so long as `a.example` returns the same object; if it
does not, this would always take the `else` branch, but that is hard to
spot and counter-intuitive considering such odd behavior is very rare.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Tuesday, 29 October 2013 14:26:09 UTC