if [llength [info commands p7proc]] { set Compiling true } else { set Compiling false source testing.tcl } if $Compiling { p7class Apple { (int)a } p7class Banana { (int)b } p7class Coconut { (int)c } p7proc (int)value { (Apple)this } { k $a } p7proc (int)value { (Banana)this } { k $b } p7proc (int)value { (Coconut)this } { k $c } p7proc (tcl)toString { (Apple)this (int)i } { ::list "apple" $a $i } p7proc (tcl)toString { (Banana)this (int)i } { ::list "banana" $b $i } p7proc (tcl)toString { (Coconut)this (int)i } { ::list "coconut" $c $i } p7proc (tcl)toString { (tcl)this (int)i } { ::list "default" $this $i } p7proc (Apple)newApple { (int)j } { new (Apple)this set a $j return $this } p7proc (Banana)newBanana { (int)j } { new (Banana)this set b $j return $this } p7proc (Coconut)newCoconut { (int)j } { new (Coconut)this set c $j return $this } p7proc (tcl)fruit { (int)aa (int)bb (int)cc (int)dd } { ::list [toString [newApple $aa] (aa*10)] [toString [newBanana $bb] (bb*10)] [toString [newCoconut $cc] (cc*10)] [toString [set (tcl) $dd] (dd*10) ] } p7proc (tcl)relayToString { (tcl)p (int)i } { toString $p $i } p7proc (tcl)relayValue { (tcl)p } { value $p } } else { AssertEq 42 {value [newApple 42]} AssertEq 43 {value [newBanana 43]} AssertEq 44 {value [newCoconut 44]} AssertError *dynamic* {value not-a-fruit } AssertEq 42 {relayValue [newApple 42]} AssertEq 43 {relayValue [newBanana 43]} AssertEq 44 {relayValue [newCoconut 44]} AssertError *dynamic* {relayValue not-a-fruit } AssertEq [list apple 100 111] {toString [newApple 100] 111} AssertEq [list banana 200 222] {toString [newBanana 200] 222} AssertEq [list coconut 300 333] {toString [newCoconut 300] 333} AssertEq [list default grape 333] {toString grape 333} AssertEq [list apple 100 111] {relayToString [newApple 100] 111} AssertEq [list banana 200 222] {relayToString [newBanana 200] 222} AssertEq [list coconut 300 333] {relayToString [newCoconut 300] 333} AssertEq [list default grape 333] {relayToString grape 333} AssertEq [list [list apple 11 110] [list banana 22 220] [list coconut 33 330] [list default 44 440]] { fruit 11 22 33 44 } Okay }