How is it needed for Map/Set? Those use SameValueZero, and don't have a
sorting method.

On Sun, Sep 18, 2016 at 10:32 PM, Park Hyeonu <nemo1...@gmail.com> wrote:

> Well, this proposal is not for check equality. Its purpose is to compare
> two object that which object is `greater`.
>
> I'm sure this feature is already implemented for every modern js engines,
> as it's needed to implement Map/Set. But we don't have js interface for it
> yet. Thus proposal is to expose this functionality to userland application.
>
> 2016. 9. 19. 오후 2:26에 "Jordan Harband" <ljh...@gmail.com>님이 작성:
>
> This may have already been proposed as https://github.com/sebmarkb
>> age/ecmascript-shallow-equal - if so, you'll want to post your comments
>> there.
>>
>> On Sun, Sep 18, 2016 at 10:10 PM, Park Hyeonu <nemo1...@gmail.com> wrote:
>>
>>> tl;dr - deterministic function that compares arbitrary objects
>>>
>>> I know now we have `Map` and `Set`, but sometimes we need more low level
>>> ones. Especially for library developers.
>>>
>>> For the case, say, I want to implement a map whose key can be a
>>> arbitrary number of objects. Currently this can only implemented as nested
>>> map whose structure is `keylen -> key1 -> key2 -> ... -> value`. Not really
>>> elegant. But if we have `Object.compare()`, `(key1, key2, ...) -> value` is
>>> possible.
>>>
>>> As its intended purpose is to be used with custom map/set, I don't think
>>> we should define how this function works in spec. Just guaranteed to be
>>> deterministic in each runtime is enough.
>>>
>>> For detail, this function follows `(left: any, right: any) => number`
>>> form. When `Object.is(left, right)` is true, `Object.compare(left, right)`
>>> must return `0`. Otherwise, the result must be deterministic, means
>>> whenever(in same runtime) we call this function with same arguments it
>>> should return same value(or at least, always greater than/lesser 0).
>>>
>>> Seems good?
>>>
>>> _______________________________________________
>>> 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

Reply via email to