Posted to tcl by hypnotoad at Mon Jun 01 16:35:09 GMT 2015view raw
- package require oo::meta
- oo::class create small_class {
- constructor {} {}
- method hello {} {puts hello}
- }
- oo::class create large_class {
- property deputy first {class small_class}
- property deputy second {class small_class}
- constructor {} {
- foreach {name desc} [my meta get deputy] {
- set class [dict get $desc class]
- set obj [$class create $name]
- my meta set child $name $obj
- $obj meta set $obj parent [self]
- }
- }
- method hello {} {
- foreach {name obj} [my meta get child] {
- $obj hello
- }
- }
- }
- large_class create myLargeObject
- myLargeObject hello
- myLargeObject first hello
- myLargeObject second hello