[squeak-dev] Re: Re: talk on Newspeak online

Stephen Pair stephen at pairhome.net
Fri May 9 20:40:33 UTC 2008


This thread is all over the map and I don't have time to read it all, so my
apologies in advance if I'm rehashing something someone already said.

I've always preferred a prototype/cloning approach rather than the
traditional initialization we find in Smalltalk.  I find that there often
isn't one properly initialized form of an instance that you need to provide,
but several or perhaps many.  One simple example is "Semaphore new" and
"Semaphore forMutualExclusion".  It's an example of two differently
initialized forms.  Instead of having two different constructor methods
(#new and #forMutualExclusion), you could have two different prototypes
initialized in the manner you want them and then clone one of them when you
need new instances.  Another interesting point is that it's the consumer of
the class that determines which form is appropriate to use, not the class
itself.  So, at the very least, you do need to support many constructors for
any given class (not all of which need be located in the same "module" as
the class itself), and perhaps you might want to do the construction in
advance and simply clone the appropriate prototype to get new instances.

However, I still use the traditional approach most often simply because I've
never bothered to create an easy frameork for creating and organizing such
prototypes.

- Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080509/467c53d7/attachment.htm


More information about the Squeak-dev mailing list