Changing Command Names with rename

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 7.  Procedures and Scope


Changing Command Names with rename

The rename command changes the name of a command. There are two main uses for rename. The first is to augment an existing procedure. Before you redefine it with proc, rename the existing command:

 rename foo foo.orig 

From within the new implementation of foo you can invoke the original command as foo.orig. Existing users of foo will transparently use the new version.

The other thing you can do with rename is completely hide a command by renaming it to the empty string. For example, you might not want users to execute UNIX programs, so you could disable exec with the following command:

 rename exec {} 

       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net