|  |  
 |   |   
 NAMEcode - capture the namespace context for a code fragment SYNOPSISitcl::code ?-namespace name? command ?arg arg ...? DESCRIPTIONCreates a scoped value for the specified command and its associated arg arguments. A scoped value is a list with three elements: the "@scope" keyword, a namespace context, and a value string. For example, the command 
namespace foo {
@scope ::foo {puts {Hello World!}}Extensions like Tk execute ordinary code fragments in the global namespace. A scoped value captures a code fragment together with its namespace context in a way that allows it to be executed properly later. It is needed, for example, to wrap up code fragments when a Tk widget is used within a namespace: 
namespace foo {
Also, note that the code command preserves the integrity of arguments on the command line. This makes it a natural replacement for the list command, which is often used to format Tcl code fragments. In other words, instead of using the list command like this: after 1000 [list puts "Hello $name!"] after 1000 [code puts "Hello $name!"] Scoped commands can be invoked like ordinary code fragments, with or without the eval command. For example, the following statements work properly: 
set cmd {@scope ::foo .b1}
$cmd configure -background red
set opts {-bg blue -fg white}
eval $cmd configure $opts
@scope ::foo {report {Hello World!}}KEYWORDSscope, callback, namespace, public, protected, private 
 
 |