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

Use WeakRef instead of ObjectSpace::WeakMap? #91

Open
nirvdrum opened this issue Oct 17, 2018 · 2 comments
Open

Use WeakRef instead of ObjectSpace::WeakMap? #91

nirvdrum opened this issue Oct 17, 2018 · 2 comments
Assignees

Comments

@nirvdrum
Copy link

Mustermann::EqualityMap uses ObjectSpace::WeakMap directly in its implementation. According to the docs for ObjectSpace::WeakMap, that class should not be used directly:

This class is mostly used internally by WeakRef, please use lib/weakref.rb for the public interface.

Of course, it exists and works, but using WeakRef instead looks like the safer option.

@namusyaka
Copy link
Member

It looks intentional. weaklef is a really thin wrapper for Object::Weakmap.

I'll let @rkh answer to this issue.

@nirvdrum
Copy link
Author

nirvdrum commented Nov 4, 2018

I think that means you're relying on implementation details. TruffleRuby's WeakRef has a different implementation that adheres to the interface, for instance. We don't currently have ObjectSpace::WeakMap, so we fall back to the Array implementation in Mustermann. We'll add ObjectSpace::WeakMap, but this caught my eye as an issue that could also be addressed by using the suggested public interface.

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

3 participants