# -*- Tcl -*- package require nx namespace path nx # Don't use test, since test and contains redefines new, # so we ahe a conflict.... #package require nx::test proc ? {cmd expected {msg ""}} { #puts "??? $cmd" set r [uplevel $cmd] if {$msg eq ""} {set msg $cmd} if {$r ne $expected} { puts stderr "ERROR $msg returned '$r' ne '$expected'" error "FAILED $msg returned '$r' ne '$expected'" } else { puts stderr "OK $msg" } } # # We define here a few attributes of type method, such we can add # arbitrary "-" calls # Class create Tree { :attribute label :attribute contains:method :attribute foo:method :public method foo {arg} {set :x $arg} } set y [Tree new -foo hu] ? [list $y eval {set :x}] hu # # actually, the intention was to define an xotcl-like -contains # set x [Tree create 1 -label 1 -contains { ? {self} ::1 ? {namespace current} ::1 Tree create 1.1 -label 1.1 Tree create 1.2 -label 1.2 -contains { ? {self} ::1::1.2 ? {namespace current} ::1::1.2 Tree create 1.2.1 -label 1.2.1 Tree create 1.2.2 -label 1.2.2 -contains { Tree create 1.2.2.1 -label 1.2.2.1 ? {self} ::1::1.2::1.2.2 } Tree create 1.2.3 -label 1.2.3 } Tree create 1.3 -label 1.3 }] puts stderr ===EXIT