RosettaCodeData/Task/Singleton/Lasso/singleton-2.lasso

17 lines
272 B
Plaintext

// Define thread level singleton
define singleton => type {
data public switch = 'x'
public oncreate => var(.type)->isa(.type) ? var(.type) | var(.type) := self
}
local(
a = singleton,
b = singleton,
)
#a->switch = 'a'
#b->switch = 'b'
#a->switch // b