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

List should be Hashable #3611

Closed
DartBot opened this issue Jun 13, 2012 · 8 comments
Closed

List should be Hashable #3611

DartBot opened this issue Jun 13, 2012 · 8 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented Jun 13, 2012

This issue was originally filed by [email protected]


and have a hashCode defined in terms of the hashCodes of its elements (like in Java).

Currently this would throw if an element wasn't hashable, if 3369 was fixed it would always be defined.

Ideally Map and Set too...

@sethladd
Copy link
Contributor

If we get this, we probably don't need Related: http://code.google.com/p/dart/issues/detail?id=3597

@kevmoo
Copy link
Member

kevmoo commented Jun 13, 2012

Strongly disagree.

List is mutable. It's easy to add/remove items from it.

If the hashCode of list is a function of its items and it's changed after it's added to a HashSet, it can be effectively lost--future attempts to find it will use the new hashCode while it's stored in buckets based on its old hashCode.

@DartBot
Copy link
Author

DartBot commented Jun 13, 2012

This comment was originally written by [email protected]


Some lists are mutable, some lists are not.

'You should not mutate lists that are keys of a hashtable' is definitely more complex than 'lists may not be keys of a hashtable'. It's also much more useful.

@DartBot
Copy link
Author

DartBot commented Jun 14, 2012

This comment was originally written by @tomyeh


IMO, it is better to make all object hashable as Java does. Please vote up Issue #3218 if you agree. Thanks.

@anders-sandholm
Copy link
Contributor

Added Area-Library, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jul 16, 2012

This comment was originally written by [email protected]


Tom: I agree Object should be hashable with identity semantics, but IMO List should be hashable with value semantics, so this is a different bug and I think we need both.

I was practicing some interview questions today, and had to switch back to Java because of this bug :-(

@DartBot
Copy link
Author

DartBot commented Jul 16, 2012

This comment was originally written by @seaneagan


this issue should be equivalent to issue #2217, which requests a value-based == for Collections, since == and hashCode must be consistent with one another.

@floitschG
Copy link
Contributor

Now that every object is hashable this issue has become a dupe of bug 2217.


Added Duplicate label.
Marked as being merged into #2217.

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report labels Nov 7, 2012
copybara-service bot pushed a commit that referenced this issue Oct 18, 2022
Changes:
```
> git log --format="%C(auto) %h %s" 817e61d..b9afe92
 https://dart.googlesource.com/pub.git/+/b9afe927 Completely switch from pub.dartlang.org to pub.dev (#3611)
 https://dart.googlesource.com/pub.git/+/7b65fa73 update docs for running 'pub token' (#3602)
 https://dart.googlesource.com/pub.git/+/4c9ebd0e Content hashing of archives (#3482)

```

Diff: https://dart.googlesource.com/pub.git/+/817e61d9eb174f77dfd2cb1d1de45826f66ac6bf~..b9afe9270c24d040b8ae465b4b37ba4f7f4b4cc5/
Change-Id: I6d827dd64f822e0194e0e17e95a47f02b744b561
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264701
Commit-Queue: Sigurd Meldgaard <[email protected]>
Reviewed-by: Jonas Jensen <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

5 participants