-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Refine the return type of hash-copy
and for/hash
s.
#1081
base: master
Are you sure you want to change the base?
Conversation
This seems like it breaks existing code, as evidenced by the PRs for other repositories. That doesn't seem like something we want to do, at least not when the breakage seems substantial as it is here. We might want to try to warn people when they do this, which perhaps might eventually let us make these changes. Unfortunately there isn't currently a good way to surface warnings to users in Racket, so there are some design considerations to be addressed first. |
I can see this difficulty. In fact, I thought about creating the PR when I discovered that there was a hidden bug in my code which should be thrown by type system. Unfortunately it seems to break too many repositories so maybe it's not a good idea to merge it now. |
I think it's safe to refine operators' return types. And the default return type of |
hash-copy
and for/hash
s.
Hi @samth, currently this PR only optimizes the return type, I think this change is safe. Will TR consider merging it? |
This has some conflicts, and also the changes to the type annotations in the tests worry me. |
I thought
I thought |
The conflict is a merge conflict, with changes to the files that have happened in the mean time. I would like to not change the tests, except perhaps for more precise types for the results. |
hash-set
,hash-set*
,hash-update
,hash-remove
, andhash-clear
should receive an immutable hash table and return an immutable hash table;hash-set!
,hash-set*!
,hash-update!
,hash-remove!
, andhash-clear!
should receive a mutable hash table and modify its state;hash-copy
should return a mutable hash table;for/hash[eq/eqv]
: should return an immutable hash table. In the older definition, ifa.ty
is false,for/hash
can't make sure the returned hash table is immutable.