Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 09, 2004 Weak references | ||||
---|---|---|---|---|
| ||||
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 |
December 09, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesper Nordenberg | 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 |
December 09, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesper Nordenberg | > 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
|
December 09, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastian Beschke | In article <cp9uft$o0v$1@digitaldaemon.com>, Sebastian Beschke says... > >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. 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!) >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 |
December 10, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote:
>>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.
Too bad. I think weak references are very useful when creating loosely coupled classes.
/Jesper
|
December 10, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesper Nordenberg | "Jesper Nordenberg" <jesper@nnl.se> wrote in message news:cpbn88$h1u$1@digitaldaemon.com... > Ben Hinkle wrote: >>>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. > > Too bad. I think weak references are very useful when creating loosely coupled classes. > > /Jesper 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. |
December 10, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote:
>>Too bad. I think weak references are very useful when creating loosely coupled classes.
>>
>>/Jesper
>
>
> 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.
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.
/Jesper
|
December 10, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote:
>>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.
It is possible to create them (without altering the GC), but it takes some rather arcane magic to do it.
|
December 10, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesper Nordenberg | On Fri, 10 Dec 2004 16:27:17 +0100, Jesper Nordenberg <jesper@nnl.se> wrote:
> Ben Hinkle wrote:
>>> Too bad. I think weak references are very useful when creating loosely coupled classes.
>>>
>>> /Jesper
>> 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.
>
> 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.
I had to do this for a few things in DFL, like menus. I accomplished it by storing the reference in malloc'd memory.
|
December 11, 2004 Re: Weak references | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | Vathix wrote:
> On Fri, 10 Dec 2004 16:27:17 +0100, Jesper Nordenberg <jesper@nnl.se> wrote:
>
>> Ben Hinkle wrote:
>>
>>>> Too bad. I think weak references are very useful when creating loosely coupled classes.
>>>>
>>>> /Jesper
>>>
>>> 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.
>>
>>
>> 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.
>
>
> 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?
Bastiaan.
|
Copyright © 1999-2021 by the D Language Foundation