overload

[General meaning in software]

[much used in Tcl]

In Tcl, to enhance a core command (or existing proc) by renaming the command to be enhanced, then creating a procedure with the same name as the core command that provides the desired functionality.

Easy example, provided by RS:

    rename exit _exit

    proc exit {{code 0}} {
        set fp [open test a]
        puts $fp "trapped exit at [clock format [clock seconds]]"
        _exit $code
    }

General case needs uplevel, as in

         uplevel 1 [linsert $args 0 _original_PROC]

or, with 8.5,

         uplevel 1 [list _original_PROC {*}$args]

See stacking.