-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hash
able wrappers for Value
#295
Comments
I've been kind of thinking that we might either want to do one of:
|
For floats, the only values that are a problem are |
Map and Set are now proper hash tables (still pointing to vectors, though; we need to know the insertion order after all); Value doesn't implement Hash but does have custom functions for hashing. |
Currently the implementations for
Set
andMap
use vectors rather than hash tables, which makes them not ideal, due toValue
not implementingHash
. This is in part due to JS values having multiple kinds of (even strict) equality, whereas there can only be oneHash
implementation for a given type.This could be solved, though, with wrapper structs over
Value
that provide aHash
implementation for each kind of equality1. This wrapper might also have to contain a pre-computed hash, if only for primitives with a heap data, since we won't have access to the agent inside theHash
implementation.While this could be implementable right now, there are things that would ease that:
SmallInteger
a wrapper overSmallBigInt
, not vice versa #288 and Consider adding a wrapper overf32
for Value #289.HeapNumber
orHeapBigInt
if an equal one already exists.NaN
and positive/negative zero), structural equality ofValue
maps to equality of JS values.Hash
forBaseIndex
and for all wrappers over one.Footnotes
Well, each kind of equality that forms an equivalence relation. There can't be a hash for triple-equals because
NaN !== NaN
, but there can be one forSameValue
andSameValueZero
. ↩The text was updated successfully, but these errors were encountered: