Updated 2015-11-13 20:57:58 by pooryorick

package forget removes the regisration information about a package that was supplied via package provide.

Synopsis  edit

package forget ?package package ...?

Description  edit

package forget does not "undo" what was done by the script evaluated in order to provide the package, which may be arbirarily complex. In the common case, the effect of loading a package is that a new namespace is created to hold the command and variables provided by the package. In this common case, follow up package forget with namespace delete to cleanly remove all vestiges of a package from an interpreter. A pure-Tcl package arrange for anything it loads to get unloaded when its namespace is deleted. Here is one way, provided by RS, to do that:
namespace eval ::foo {
    variable cleanup 0
 
    proc cleanup {} {
        # do cleanup
    }
    trace add variable ::foo::cleanup unset ::foo::cleanup
}

An extension can take advantage of the delete callback slot in Tcl_CreateObjCmd to do any cleanup, including unloading of any shared objects.

Page authors  edit

PYK
RS
schlenk