Pool dictionaries

Dave Astels astels at audesi.com
Thu Oct 29 13:25:46 UTC 1998

Blanchard, Tod wrote:

> Could somebody explain PoolDictionary in the class definition pane?  What
> are they and why would I want one?  Thanks.

They are hashtables like Smalltalk.  They hold named objects (named via
the hash keys) that you might want to have free access to in some set of
classes, but not have the namespace polluted where they aren't needed. 
An example is the set of Character constants stored in the global
Dictionary (i.e. it's stored in Smalltalk) TextConstants.  In here for
example is an entry named 'Space' having a value of the space character
(ASCII 32).  If you use TextConstants as a PoolDictionary in a class
then you have access to elements of that Dictionary as if they were
class variables (i.e. you just have to reference 'Space' if you want the
space character.

For an example in Squeak, look at the class CharacterBlockScanner in
category Graphics-Support.  It uses TextConstants as a pool dictionary. 
If you look in the 'cr' method in the 'stop conditions' protocol you can
see reference to 'CR' which is an entry in TextConstants:

characterPoint _ ((text at: lastIndex) = CR
			ifTrue: [leftMargin]
			ifFalse: [nextLeftMargin])

I hope this helps.

Dave Astels                     The people who are crazy enough
Software Engineer               to think they can change the world,
AudeSi Technologies Inc.        are the ones who do.
astels at audesi.com (work)	01490312 at 3web.net (home)

More information about the Squeak-dev mailing list