_namespace import_ and _rename_

In tcl threads 2.1 question? , comp.lang.tcl, 2001-09-05, Donald Porter gives a very nice example of the freedom that the programmer gains through the proper use of namespaces.

The example speaks for itself:

# Someone provides the thread package with a thread::shared command:
namespace eval thread {
    namespace export shared
    proc shared {option args} {...}
}

# Author of the foo package has different opinions about names:
namespace eval foo {
    namespace import ::thread::shared
    # Shared what?  What a stupid ambiguous name!
    rename shared sharedVariable
    proc myLongCommandName {} {...; sharedVariable set counter 1; ...}
}

# Author of the bar package has yet a third view:
namespace eval bar {
    namespace import ::thread::shared
    # Stpd thrd pkg gonna give me RSI.
    rename shared sv
    proc x {} {...; sv set x 1; ...}
}