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.




fn Singleton()
	if this.self then return this.self cls
	var new: {}
	iter k,v as this._props do
		new[k]:v
	cls
	this.self:new
	return new
cls
Singleton._props: {
	name: "Singleton",
	fn setName(self,new)
		self.name:new
	cls,
}
 
var MySingleton: Singleton()
log(MySingleton == Singleton()) --true
log(MySingleton.name) --Singleton
 
var NewSingleton: Singleton()
NewSingleton>>setName("Test")
 
log(MySingleton.name) --Test