logoalt Hacker News

sfinktoday at 5:40 AM0 repliesview on HN

Yes, WeakRef and FinalizationGroup both make GC visible (the latter removes the need to poll in your example). So not pedantic at all. They were eventually added after much reluctance from the language designers and implementers, partly because they can lead to code being broken by (valid & correct) engine optimizations, which is a big no-no on the web. But some things simply cannot be implemented without them.

Note that 90% of the uses for them actually shouldn't be using them, usually for subtle reasons. It's always a big cause for debate.