Array#sort() implementations not interoperable
rossberg at google.com
Fri Jun 14 00:55:29 PDT 2013
On 14 June 2013 09:50, David Bruant <bruant.d at gmail.com> wrote:
> And this particular behavior might be standardizable without a loss (even
> with a gain), because:
> 1) a sort algorithm only needs all the array values once at least once
> (serie of [[Get]]s) and should probably avoiding touching the array again
> since getter or get traps may be costly and return inconsistent values (so
> [[Get]] the values at most once)
> 2) the sorting algorithms is on the values, not on the array (though with
> membranes, if the comparator function touches more than the object identity,
> it can be observable, but that's not the problem of the sort algorithm)
> 3) No sort algorithm requires to rearrange more elements than the number
> there is in the array.
Given that you can still observe implementation-dependent invocations
of the comparison function I don't see what is really gained by this.
Trying to make a complex operation like sorting fully deterministic is
a fruitless endeavour in an impure language.
More information about the es-discuss