Um, then it's reasonable implementation. But it can be far much optimized
with native implementation(naively say, pointer comparison?).

Anyway, we should not decide to include something in spec because it
can/cannot be implemented. And this proposal can make additional
possibility to js libraries.

For example, facebook/ImmutableJS currently uses array-based O(n) approach
for it's Map/Set structure. Because there's still no way to compare
arbitrary objects in js. Yes, O(n) for search!

2016. 9. 19. 오후 6:44에 "Michał Wadas" <michalwa...@gmail.com>님이 작성:

> If you call such implementation million times per second, you would need
> ~280 years to exhaust 2^53 values. So it's definitely a long running
> program.
>
> On 19 Sep 2016 11:28 a.m., "Park Hyeonu" <nemo1...@gmail.com> wrote:
>
>> I'm definitely not a js engine expert but isn't there some
>> pointer-of-pointer thingy that points rearranged position(maybe called
>> handle)?
>>
>> I leaved the exact comparing rule as black box and let engines care such
>> cases. The single rule is that it should be deterministic.
>>
>> Anyway, your WeakMap-based implementation can easily exceeds
>> Number.MAX_SAFE_INTEGER with some long-running application, as numbers
>> cannot be reused.
>>
>> 2016. 9. 19. 오후 6:03에 "Michał Wadas" <michalwa...@gmail.com>님이 작성:
>>
>>>
>>> On Mon, Sep 19, 2016 at 7:32 AM, Park Hyeonu <nemo1...@gmail.com> wrote:
>>>
>>>> I'm sure this feature is already implemented for every modern js
>>>> engines, as it's needed to implement Map/Set.
>>>>
>>>
>>> But you know that, it's indeterministic and implementation is free to
>>> reorganize pointers?
>>>
>>> a = {}; b = {};
>>> Object.compare(a,b); // 1
>>> gc.enforceGC();
>>> Object.compare(a,b); // -1
>>>
>>> So any userland structure can't rely on persistence of order.
>>>
>>> Moreover, such ordering can be implemented with WeakMap.
>>>
>>> const wm = new WeakMap()
>>> let i = 0;
>>> function getId(obj) {
>>>     if (!wm.has(obj))
>>>         wm.set(obj, i++);
>>>     return wm.get(obj);
>>> }
>>>
>>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to