Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Bert Freudenberg
Am 15.07.2008 um 08:26 schrieb Herbert König: Hello Randal, RLS> dictionary. This is how the classic "dependents" system works as well: the RLS> dependencies are in a WeakDictionary so that when the watched object goes RLS> away, the dependencies are also cleaned. thanks for some free e

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Herbert König
Hello Randal, RLS> dictionary. This is how the classic "dependents" system works as well: the RLS> dependencies are in a WeakDictionary so that when the watched object goes RLS> away, the dependencies are also cleaned. thanks for some free education (no smiley, I mean it), now I'll do some homew

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Randal L. Schwartz
> "Herbert" == Herbert König <[EMAIL PROTECTED]> writes: Herbert> Hello cdrick, c> All that sounds like "don't use weak reference" :) Herbert> unless you know exactly what you are doing. One possible use I haven't seen in this thread is to "keep notes" on a class you don't own (and don'

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Bert Freudenberg
Am 15.07.2008 um 06:42 schrieb Marcin Tustin: One of the uses of weak references in other languages is to keep a collection of all the instances of a class without preventing them being garbage collected. Obviously, this is not necessary in squeak. One major use in Squeak is for ensuring t

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Marcin Tustin
One of the uses of weak references in other languages is to keep a collection of all the instances of a class without preventing them being garbage collected. Obviously, this is not necessary in squeak. On 7/15/08, Herbert König <[EMAIL PROTECTED]> wrote: > > Hello cdrick, > > > c> All that sounds

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Michael Davies
On Tue, Jul 15, 2008 at 2:39 PM, cdrick <[EMAIL PROTECTED]> wrote: > All that sounds like "don't use weak reference" :) > > > Cédrick > A nice clear summary! Thanks to all who have posted on this topic - it's been a very useful discussion. Michael ___

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Herbert König
Hello cdrick, c> All that sounds like "don't use weak reference" :) unless you know exactly what you are doing. -- Cheers, Herbert ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/li

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread cdrick
All that sounds like "don't use weak reference" :) Cédrick ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread David T. Lewis
On Mon, Jul 14, 2008 at 10:43:30PM -0700, Bert Freudenberg wrote: > > In a clean design you very rarely need weak refs. Also, you need to > sprinkle your code with ifNil: tests because a weak ref can become nil > any time. It is also worth mentioning that weak references can lead to performan

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Michael van der Gulik
On Mon, 14 Jul 2008 12:07:51 +0200 "Michael Davies" <[EMAIL PROTECTED]> wrote: > On Sun, Jul 13, 2008 at 6:15 PM, Rob Rothwell <[EMAIL PROTECTED]> wrote: > > Can someone explain what a "weak" vs (I am guessing) "strong" reference is? > [snip] > > I, too, am maintaining parent/child relationships i

Re: [Newbies] What is a "weak" reference

2008-07-15 Thread Herbert König
Hello Michael, MD> Thanks, that's interesting - does that mean that the parent-child MD> linkage in Rob's example isn't the root cause of his problem? see Bert's reply, he knows why it is so, I only know that I do it all the time (circular links) and it never prevents GC. -- Cheers, Herbert

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Bert Freudenberg
Am 14.07.2008 um 09:51 schrieb Rob Rothwell: On Mon, Jul 14, 2008 at 11:42 AM, Todd Blanchard <[EMAIL PROTECTED]> wrote: So how do you make a weak reference? You stick a WeakArray in as a holder. So in your parent/child objects you would write something like: Node>>parent ^ paren

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Michael Davies
On Mon, Jul 14, 2008 at 4:43 PM, Herbert König <[EMAIL PROTECTED]> wrote: > Hello Michael, > > > Child>>>parent > MD> ^ Parent allInstances detect: [ :each | each children includes: self ] > > allInstances scans *every* object in the image which is slow. Ouch, I can see that it would be :-) >

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Rob Rothwell
On Mon, Jul 14, 2008 at 11:42 AM, Todd Blanchard <[EMAIL PROTECTED]> wrote: > So how do you make a weak reference? You stick a WeakArray in as a holder. > So in your parent/child objects you would write something like: > > Node>>parent >^ parent ifNotNil: [parent first] ifNil: [parent] >

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Todd Blanchard
A weak reference is simply a reference that will not prevent an object from being garbage collected. It is common to use a weak reference in back pointers when you know you are having circularities. It is practically a pattern, when building a hierarchy of objects, to make the parent poin

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Herbert König
Hello Michael, Child>>>parent MD> ^ Parent allInstances detect: [ :each | each children includes: self ] allInstances scans *every* object in the image which is slow. The garbage collector needs a path to a root object (whatever that is) so a purely circular reference does not prevent garba

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Randal L. Schwartz
> "Michael" == Michael Davies <[EMAIL PROTECTED]> writes: Michael> I note that there are very few uses of any Weak* classes in the image, Michael> so it's likely that there is a better way of implementing what you're Michael> aiming for; eg the child could drop its direct parent reference, and

Re: [Newbies] What is a "weak" reference

2008-07-14 Thread Michael Davies
On Sun, Jul 13, 2008 at 6:15 PM, Rob Rothwell <[EMAIL PROTECTED]> wrote: > Can someone explain what a "weak" vs (I am guessing) "strong" reference is? [snip] > I, too, am maintaining parent/child relationships in my application and have > just been doing something like: > Parent>>createChild >

[Newbies] What is a "weak" reference

2008-07-13 Thread Rob Rothwell
Can someone explain what a "weak" vs (I am guessing) "strong" reference is? I have been struggling with Garbage Collection for quite some time now and saw this on another list: "You'll need to add an instance variable to process and modify fork to record the origin. Currently processes don't reme