Did you delete a post? I'm seeing an earlier date/time on a follow-up posting.
I also see m, m1, and method_m, in 3 posts are they all the same?
If so, is this a tcl procedure or a command implemented in C code? You show these with ()'s and use // for online comments, which is used in C code. The ()'s are not needed in Tcl.
I might do it this way (assuming method_m is a tcl proc):
proc func {args} { ;# can be called with 0 or more args
puts "In function"
}
rename func func_orig
proc func {args} { ;# original plus additional call to method_m
func_orig {*}$args ;# call original with any args (or none) called with
method_m
}
proc method_m {} {
if {[info command func_orig] eq ""} { ;# needs to know who to call
func ;# new_proc hasn't yet been defined, use original name
} else {
func_orig ;# call the original version that now has this name
}
}
I've guessed the actual problem is that method_m code really needs to always call the original version of func, but could be called both before and after the rename takes place.
This way you only do the one rename (and one redefine of func), and don't rename it back.
If I guessed wrong, well....ignore me :)