Skip to content
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

Support ES6 Symbols #53

Open
chocolateboy opened this issue Oct 9, 2017 · 1 comment
Open

Support ES6 Symbols #53

chocolateboy opened this issue Oct 9, 2017 · 1 comment

Comments

@chocolateboy
Copy link

Symbols are unique, so the implementation added in #23 doesn't work as expected e.g.:

$ replem object-hash:hash

> s1 = Symbol("foo")
Symbol(foo)

> s2 = Symbol("foo")
Symbol(foo)

> s1 === s2
false

> o = { [s1]: "s1", [s2]: "s2" }
> o[s1] === o[s2]
false

> hash(s1) === hash(s2)
true

The last test should return false because the values are as distinct as two different numbers.

@addaleax
Copy link
Collaborator

The last test should return false because the values are as distinct as two different numbers.

The only issue is: how? I don’t think this would be possible without a global list of symbols that have been seen, but you really want a hash function to not depend on mutable global state, so … hm. You might be right, but this might just not be possible to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants