Bug 4151 – Add weak references to Phobos/druntime

Status
REOPENED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-05-02T20:55:00Z
Last change time
2024-12-01T16:13:23Z
Assigned to
No Owner
Creator
nfxjfg
Blocks
9606
Moved to GitHub: phobos#9885 →

Comments

Comment #0 by nfxjfg — 2010-05-02T20:55:00Z
Just that. The Java API documentation may provide a good starting point as to what weak references should be able to do: http://java.sun.com/javase/7/docs/api/java/lang/ref/WeakReference.html Note that finalizers and the "hidden" rt_attach.../detach... functions are highly unsafe and hard to get right. As an example what can go wrong if users try to implement their own weak references, see bug 4150.
Comment #1 by verylonglogin.reg — 2013-03-16T05:06:59Z
Even worse GC lock/unlock aren't parts of a druntime user API so one have to use ugly things like calling addRange/removeRange to ensure the memory will not be collected.
Comment #2 by verylonglogin.reg — 2013-10-08T02:58:32Z
Comment #3 by verylonglogin.reg — 2013-10-16T02:58:28Z
A proposal to add library implementation without runtime changes: http://forum.dlang.org/thread/[email protected]
Comment #4 by dmitry.olsh — 2018-05-17T12:27:26Z
Even in Java Weak references solve about as much problems as they introduce. But a library based solution could indeed come in handy.
Comment #5 by robert.schadek — 2024-12-01T16:13:23Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9885 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB