A Global Singleton is a class of which only one instance exists within a program.

Any attempt to use non-static members of the class involves performing operations on this one instance.




Singleton ::= Object clone tap {
  self id := 0.
  self newID := {
    self id := self id + 1.
  }.
  self clone := {
    err ArgError clone tap { self message := "Singleton object!". } throw.
  }.
}.
 
println: Singleton newID. ; 1
println: Singleton newID. ; 2
println: Singleton newID. ; 3