Skip to content

WeakMap remove .clear()? #1539

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

Closed
kitsonk opened this issue Sep 3, 2016 · 2 comments
Closed

WeakMap remove .clear()? #1539

kitsonk opened this issue Sep 3, 2016 · 2 comments

Comments

@kitsonk
Copy link

kitsonk commented Sep 3, 2016

Are there any plans to remove .clear() from WeakMap to make the implementation compliant with the specification? Other engines have removed it and aligned to the final spec. Having deprecated/removed API isn't a zero sum game as it maintaining the feature in perpetuity can have future consequences and developers can latch onto functionality that they shouldn't. Wouldn't it be better to "break" anyone mistanklingly using this API now than in 10 years.

I would have also assumed by the nature of the ECMAScript WeakMap that there could be an optimisation by not having to track the pointers in the map directly in the WeakMap to support clear, making the GC algorithm/detection more efficient.

@bterlson
Copy link
Contributor

bterlson commented Sep 3, 2016

I didn't think this was actually exposed to script so it might be dead code? Can't confirm at the moment though...

@ianwjhalliday ianwjhalliday self-assigned this Sep 3, 2016
@ianwjhalliday
Copy link
Collaborator

This Clear method is not exposed to JavaScript. It is used by the WeakMap finalizer to remove all of its references from the key objects when the WeakMap itself is garbage collected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants