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" <[email protected]> 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" <[email protected]>님이 작성: > >> >> On Mon, Sep 19, 2016 at 7:32 AM, Park Hyeonu <[email protected]> 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 [email protected] https://mail.mozilla.org/listinfo/es-discuss

