How do I remove a Tcl procedure?
Asked Answered
N

1

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.

Natter answered 27/3, 2012 at 11:2 Comment(2)
person who voted to close: really? A programming question about a programming language is off-topic to a programming site?Kudos
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.Committeewoman
D
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"
%
Delores answered 27/3, 2012 at 11:26 Comment(1)
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...Natter

© 2022 - 2024 — McMap. All rights reserved.