Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!news.uoregon.edu!news.bc.net!info.ucla.edu!news.ucdavis.edu!csus.edu!netcom.com!jnedzel
From: jnedzel@netcom.com (Jared Nedzel)
Subject: Re: what is a WeakDictionary?
Message-ID: <jnedzelDCqJx9.FG9@netcom.com>
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: <3vq7a5$pl1@news.Austria.EU.net>
Date: Thu, 3 Aug 1995 12:55:57 GMT
Lines: 39
Sender: jnedzel@netcom.netcom.com

In article <3vq7a5$pl1@news.Austria.EU.net> Mike Rimkus <rimkus> writes:
>I'm a C++, not a Smalltalk, programmer, by practice.
>
>I've seen a WeakDictionary mentioned as a sort of representation for a
>relational DB table, which interests me. Could someone explain to me what a
>WeakDictionary is? (Offline, of course.) I'm familiar with the standard
>Smalltalk classes, like those found in Digitalk's.
>


Are you familiar with Dictionaries in general?  A dictionary is a type
of collection where you access the values via a key.  For example,
you might have a Movie dictionary:

key	Value
---	-----
#flops  {"Ishtar" "Waterworld"}
#scifi  {"2001" "Star Trek" "Blade Runner" }
.....

A WeakDictionary is a particular flavor of Dictionary created by
ParcPlace.  The difference between a regular dictionary and a weakDictionary
is that a weakDictionary's references won't prevent a value from being
garbage collected away.  In smalltalk, the garbage collector will collect
away any object that has no references pointing to it.  So if a value
is in a Dictionary, it won't  get garbage collected.  If a value is in
a weakDictionary it may get garbage collected away (if nothing else is
referencing it.)

WeakDictionaries are typically used by PP Smalltalk in GUI classes.

So, that's a long way of saying that WeakDictionaries are a peculiarity of
a garbage collected language.

-- 
-------------------------------------------------------------------------
Jared Nedzel  					jnedzel@netcom.com

Just because I'm paranoid doesn't mean there isn't someone out to get me
-------------------------------------------------------------------------
