Skip to content

Add Hashable wrappers for Value #295

Closed
@andreubotella

Description

@andreubotella

Currently the implementations for Set and Map use vectors rather than hash tables, which makes them not ideal, due to Value not implementing Hash. This is in part due to JS values having multiple kinds of (even strict) equality, whereas there can only be one Hash implementation for a given type.

This could be solved, though, with wrapper structs over Value that provide a Hash 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 the Hash implementation.

While this could be implementable right now, there are things that would ease that:

Footnotes

  1. 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 for SameValue and SameValueZero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions