mustermann
mustermann copied to clipboard
Use WeakRef instead of ObjectSpace::WeakMap?
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.
It looks intentional. weaklef is a really thin wrapper for Object::Weakmap
.
I'll let @rkh answer to this issue.
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.