Posted to tcl by lua at Tue Jun 28 00:46:39 GMT 2011view raw
- require "object"
- x = Object { f1 = "x.f1" }
- function x:print1(stg)
- print("stg is ", stg, " and f1 is ", self.f1)
- end
- w = x { f1 = "w.f1"; f2 = "w.f2" }
- function w:print2(stg)
- print("stg is ", stg, " and f2 is ", self.f2)
- end
- x1 = x {}
- x1.f1 = "no longer x.f1"
- x1:print1("from x1")
- x2 = x {}
- x2:print1("from x2")
- w1 = w {}
- w1:print1("from w1")
- w1:print2("from w1")