beetlebug▾
/

namespace upvar

Links local names to variables of a namespace.

namespace upvar NS OTHERVAR MYVAR ?OTHERVAR MYVAR ...?

Description

For each pair, makes the local name MYVAR a link to the variable OTHERVAR of the namespace NS, as upvar does for a caller. A read or a write of MYVAR reads or writes the variable of NS. The variable need not exist yet.

Arguments

ArgumentTypeDefaultDescription
NSnamespace namerequiredThe namespace of the variables.
OTHERVARvariable namerequiredA variable of NS.
MYVARvariable namerequiredThe local name of the link.

Returns

An empty string.

Examples

% namespace eval cb {variable n 3}
> proc pu {} {namespace upvar ::cb n local; incr local}
> pu
> set cb::n
4

Errors

% namespace upvar cb n
wrong # args: should be "namespace upvar ns ?otherVar myVar ...?"
-errorcode TCL WRONGARGS

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also