Search code examples
tclprocedureundef

How do I remove a Tcl procedure?


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.


Solution

  • Use rename to delete a proc

    rename myproc ""
    

    Example:

    % proc myproc {} {
        puts "hello world"
    }
    % myproc
    hello world
    % rename myproc ""
    % myproc
    invalid command name "myproc"
    %