Index: generic/predefined.xotcl =================================================================== diff -u -ra59ed987404cf38f027209a4e140569c62721bd6 -r962c96dcc0ddc25782570a831c104fb2b955891d --- generic/predefined.xotcl (.../predefined.xotcl) (revision a59ed987404cf38f027209a4e140569c62721bd6) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 962c96dcc0ddc25782570a831c104fb2b955891d) @@ -88,11 +88,37 @@ return $result } - Class method unknown {args} { - puts stderr "use '[self] create $args', not '[self] $args'" - eval my create $args + # define method modifiers "object", "public" and "protected" + Object method -public public {args} { + set p [lsearch -regexp $args {^(method|alias|forward|setter)$}] + if {$p == -1} {error "$args is not a method defining method"} + set r [{*}.$args] + ::xotcl::methodproperty [self] $r protected false + return $r } + Object method -public protected {args} { + set p [lsearch -regexp $args {^(method|alias|forward|setter)$}] + if {$p == -1} {error "$args is not a method defining command"} + set r [{*}.$args] + ::xotcl::methodproperty [self] $r [self proc] true + return $r + } + + Class method -public object {args} { + set p [expr {[lsearch -regexp $args {^(method|alias|forward|setter)$}] + 1}] + set cmd [linsert $args $p "-per-object"] + return [{*}.$cmd] + } + + # + # unknown handlers + # + Class method unknown {m args} { + error "Method '$m' unknown for [self]. Consider '[self] create $m $args' instead of '[self] $m $args'" + #eval my create $args + } + Object method unknown {m args} { if {![self isnext]} { error "[self]: unable to dispatch method '$m'"