digitalmars.D - Weak references
- Jesper Nordenberg (3/3) Dec 09 2004 I'm new to D. Are there any equivalents of Java's WeakReference and
- Sebastian Beschke (6/9) Dec 09 2004 Depends on who you ask :)
- Ant (7/14) Dec 09 2004 this is the greatest compliment, no not toleds, but
- Ben Hinkle (5/7) Dec 09 2004 nope. I don't have any links handy but I remember it coming up on the
- Jesper Nordenberg (4/12) Dec 10 2004 Too bad. I think weak references are very useful when creating loosely
- Ben Hinkle (6/19) Dec 10 2004 Can you give more details? The current design won't change without makin...
- Jesper Nordenberg (15/25) Dec 10 2004 I typically use weak references for listeners in Java. You might have an...
- Vathix (4/19) Dec 10 2004 I had to do this for a few things in DFL, like menus. I accomplished it ...
- Bastiaan Veelo (3/29) Dec 11 2004 I am very interested in this. Where can I find the details?
- Vathix (30/33) Dec 11 2004 Something like this. It's just an idea, it won't compile as-is:
- Russ Lewis (3/11) Dec 10 2004 It is possible to create them (without altering the GC), but it takes
I'm new to D. Are there any equivalents of Java's WeakReference and SoftReference in D? What is the recommended IDE for developing in D? /Jesper
Dec 09 2004
Jesper Nordenberg wrote:What is the recommended IDE for developing in D?Depends on who you ask :) I'll go ahead and recommend Ant's LEDS at http://leds.sf.net/ even though I've never used it. Apart from that, jEdit (http://www.jedit.org/) is doing quite OK for me, too :)/Jesper
Dec 09 2004
In article <cp9uft$o0v$1 digitaldaemon.com>, Sebastian Beschke says...Jesper Nordenberg wrote:this is the greatest compliment, no not toleds, but to my marketing strategy until now! :) of course it's http://leds.sourceforge.net/ (see, I never loose an opportunity to divulgate leds url!)What is the recommended IDE for developing in D?Depends on who you ask :) I'll go ahead and recommend Ant's LEDS at http://leds.sf.net/ even though I've never used it.Apart from that, jEdit (http://www.jedit.org/) is doing quite OK for me, too :)also check http://www.prowiki.org/wiki4d/wiki.cgi?EditorSupport Ant
Dec 09 2004
Are there any equivalents of Java's WeakReference and SoftReference in D?nope. I don't have any links handy but I remember it coming up on the newsgroup before and it didn't seem likely to show up any time soon if at all. It complicates the GC too much (or something like that) for too little benefit. -Ben
Dec 09 2004
Ben Hinkle wrote:Too bad. I think weak references are very useful when creating loosely coupled classes. /JesperAre there any equivalents of Java's WeakReference and SoftReference in D?nope. I don't have any links handy but I remember it coming up on the newsgroup before and it didn't seem likely to show up any time soon if at all. It complicates the GC too much (or something like that) for too little benefit.
Dec 10 2004
"Jesper Nordenberg" <jesper nnl.se> wrote in message news:cpbn88$h1u$1 digitaldaemon.com...Ben Hinkle wrote:Can you give more details? The current design won't change without making an argument to change it and the argument will heavily depend on use cases and how hard the alternative designs are. So the more examples we have of people using weak references the better.Too bad. I think weak references are very useful when creating loosely coupled classes. /JesperAre there any equivalents of Java's WeakReference and SoftReference in D?nope. I don't have any links handy but I remember it coming up on the newsgroup before and it didn't seem likely to show up any time soon if at all. It complicates the GC too much (or something like that) for too little benefit.
Dec 10 2004
Ben Hinkle wrote:I typically use weak references for listeners in Java. You might have an object A listening on another object B, but you don't want to prevent A from being GC'ed just because B keeps a reference to it. When there are no other references to A beside the one in B, you want the listener to be automatically removed from B. This scenario is very common in for example GUI applications. Another scenario is when you want to minimize the dependencies between classes and thus store information about an object in a map rather than storing the information inside the object. When the object is GC'ed you want to remove the entry from the map. In Java this is easily solved by using a WeakHashMap which automatically removes the key-value pair from the map when the key is GC'ed. Maybe there are other ways besides weak references to solve this in D. /JesperToo bad. I think weak references are very useful when creating loosely coupled classes. /JesperCan you give more details? The current design won't change without making an argument to change it and the argument will heavily depend on use cases and how hard the alternative designs are. So the more examples we have of people using weak references the better.
Dec 10 2004
On Fri, 10 Dec 2004 16:27:17 +0100, Jesper Nordenberg <jesper nnl.se> wrote:Ben Hinkle wrote:I had to do this for a few things in DFL, like menus. I accomplished it by storing the reference in malloc'd memory.I typically use weak references for listeners in Java. You might have an object A listening on another object B, but you don't want to prevent A from being GC'ed just because B keeps a reference to it. When there are no other references to A beside the one in B, you want the listener to be automatically removed from B. This scenario is very common in for example GUI applications.Too bad. I think weak references are very useful when creating loosely coupled classes. /JesperCan you give more details? The current design won't change without making an argument to change it and the argument will heavily depend on use cases and how hard the alternative designs are. So the more examples we have of people using weak references the better.
Dec 10 2004
Vathix wrote:On Fri, 10 Dec 2004 16:27:17 +0100, Jesper Nordenberg <jesper nnl.se> wrote:I am very interested in this. Where can I find the details? Bastiaan.Ben Hinkle wrote:I had to do this for a few things in DFL, like menus. I accomplished it by storing the reference in malloc'd memory.I typically use weak references for listeners in Java. You might have an object A listening on another object B, but you don't want to prevent A from being GC'ed just because B keeps a reference to it. When there are no other references to A beside the one in B, you want the listener to be automatically removed from B. This scenario is very common in for example GUI applications.Too bad. I think weak references are very useful when creating loosely coupled classes. /JesperCan you give more details? The current design won't change without making an argument to change it and the argument will heavily depend on use cases and how hard the alternative designs are. So the more examples we have of people using weak references the better.
Dec 11 2004
Something like this. It's just an idea, it won't compile as-is: class Item // Item you want weak references to. { this() { addItem(this); } ~this() { removeItem(this); } } Item[] refItems; // malloc'd memory holding weak references to Item`s. void addItem(Item item) { refItems = realloc(refItems, count * Item.sizeof); refItems[i] = item; } void removeItem(Item item) { int i; for(i = 0; i != refItems.length; i++) { if(item == refItems[i]) { refItems = realloc(refItems, count * Item.sizeof); break; } } }I had to do this for a few things in DFL, like menus. I accomplished it by storing the reference in malloc'd memory.I am very interested in this. Where can I find the details?
Dec 11 2004
Ben Hinkle wrote:It is possible to create them (without altering the GC), but it takes some rather arcane magic to do it.Are there any equivalents of Java's WeakReference and SoftReference in D?nope. I don't have any links handy but I remember it coming up on the newsgroup before and it didn't seem likely to show up any time soon if at all. It complicates the GC too much (or something like that) for too little benefit.
Dec 10 2004