Bug #16959

Updated by headius (Charles Nutter) over 3 years ago

Weakmap is still described as an internal API, and the documentation points users at WeakRef as the official public API: 

 However there are now specs for its current set of features, even though those features have never been discussed or approved as a public API: 

 And we are starting to see it being used by the community: 


 One of two things needs to happen: 

 * Weakmap is made a public API after some discussion. It would be an official public feature only in 2.8/3.0 or higher. 
 * The specs are be removed and Weakmap remains a private API not to be used by the community. I suspect the addition of the specs led to folks starting to use this private API. 

 (edit: The Rails PR was merged after the specs, but the change is actually a year old, as mentioned below. In any case there's plenty of in-the-wild uses of WeakMap that go back even further.) 

 Personally, I'm in much more in favor of making WeakRef support all the features necessary to implement Weakmap in pure Ruby, rather than the other way around: 

 But whatever happens it needs to happen soon, since this use case is now a merged feature in Rails master.