Tcl7.6 User Commands Man Page -- private (n)
Table of Contents


NAME

private - create commands/variables with "private" access

SYNOPSIS

private command ?arg arg ...?

DESCRIPTION

Sets the protection level for new commands/variables to "private" and then evaluates the remaining arguments. Note that the default protection level for commands/variables is "public". Commands and variables can also be "protected".

The command argument may be a command name like proc or variable, or a script full of command/variable declarations. Any command that creates another command or variable can be used in conjunction with the private command. For example, if widget commands are executed via "private", the widget access commands will be private.

Private commands/variables are only accessible in the namespace where they are defined.

EXAMPLE

namespace foo {
private {
variable x 0
variable y 1
}
private proc check {} {
global x y
return "$x $y"
}
}

namespace foo { ;# access allowed
check
}

foo::check
;# access denied

KEYWORDS

import, namespace, private, protected, public, variable, proc


Table of Contents