16

How do I remove a tcl procedure?

One can

  • unset a variable,
  • override an alias with interp alias {} myproc {} otherproc,
  • override a proc with one defined inside another namespace with namespace import -force.

But I did not find a way to make a procedure unknown.

cfi
  • 10,915
  • 8
  • 57
  • 103
  • 4
    person who voted to close: really? A programming question about a programming language is off-topic to a programming site? – glenn jackman Mar 27 '12 at 13:24
  • 1
    Seems like a perfectly reasonable question to me. Admittedly, fairly easy to answer with a google search but, to be fair, one of the goals of SO is to BE that result on google search when you look for such an answer. – RHSeeger Mar 27 '12 at 15:08

1 Answers1

22

Use rename to delete a proc

rename myproc ""

Example:

% proc myproc {} {
    puts "hello world"
}
% myproc
hello world
% rename myproc ""
% myproc
invalid command name "myproc"
%
Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
TrojanName
  • 4,853
  • 5
  • 29
  • 41
  • For proc's imported from a namespace `rename namespace_name::proc_name` and the locally imported name vanishes, too. Thanks! Life can be so simple sometimes... – cfi Mar 27 '12 at 11:31