[Xotcl] Help with singleton design pattern

Artur Trzewik mail at xdobry.de
Tue Apr 22 21:21:13 CEST 2003


Hallo!

As singleton objects I often use Objects directly derived from Object

Object MySingleton
MySingleton proc doJob {} {
   puts "This is my job"
}

MySingleton doJob

This is not singleton pattern but is same cases you do not need some
Java, C++ solution.
One disadvantage is that you can not use method inheritance.

By the way.
The presented solution from G. Neumann.
That is to overwrite "new" method that returns singleton object
is the standard way to implements singleton in Smalltalk
(the singleton instance is saved in class variable Default).
That is XOTcl! "new" is just method not special operator and can
be overwritten.

Artur Trzewik





More information about the Xotcl mailing list