instances that know #new, and Perl OO

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue May 20 02:02:28 UTC 2003


merlyn at stonehenge.com (Randal L. Schwartz) asks about #new.

I did once have a use for a class whose instances supported #new.
It was along the lines of

    Object subclass: #ThingFactory
        instanceVariableNames: '......'
        ...

    ThingFactory>>new
        "create, initialise, and return a new Thing"

    ThingFactory class>>new
	"create, initialise, and return a new ThingFactory"

ThingFactories were passed to an object which was documented as
expecting classes, but it only needed instance creation, and
ThingFactory implemented enough of the instance creation stuff
to work (in context).

Point is, ThingFactory>>new didn't make ThingFactories,
it made Things.  It was every bit as much unlike a "copy" method
as the ordinary use of #new.



More information about the Squeak-dev mailing list