type RefCell = [set = /[Int Sig] get = /[/Int] ] def cellConstructor() : RefCell = ( new contents:^Int run contents!0 [set = \[v:Int c:Sig] = contents?_ = (contents!v | c![]) get = \[res:/Int] = contents?v = (contents!v | res!v) ] ) run( val ref1 = (cellConstructor) val ref2 = (cellConstructor) (ref1.set 5); (ref2.set 2); (prNL (int.toString (ref1.get))); (prNL (int.toString (ref2.get))); () ) {-- new contents:^Int run contents!0 def set[v:Int c:Sig] = contents?_ = (contents!v | c![]) def get[res:/Int] = contents?v = (contents!v | res!v) def res i:Int = printi!i def done [] = get![res] run set![5 done] run ((set 5); (prNL (int.toString (get))); ()) --}