diff options
author | Geoff Liu <g@geoffliu.me> | 2015-08-30 14:22:11 -0600 |
---|---|---|
committer | Geoff Liu <g@geoffliu.me> | 2015-08-30 14:22:11 -0600 |
commit | eb7e58d5fc649ed2713c7685539bd5edcd9e8ade (patch) | |
tree | 72a9fe5106bed0735089b5c7a2b22540f7ebb3a7 /tcl.html.markdown | |
parent | 1d1def16a5d7925bb8f7fba7dc49182e33359e85 (diff) | |
parent | b124fd58df56a5e1ee9925481fbde1f22ccfb386 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'tcl.html.markdown')
-rw-r--r--[-rwxr-xr-x] | tcl.html.markdown | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tcl.html.markdown b/tcl.html.markdown index 198f675e..9ca32f1e 100755..100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -121,7 +121,8 @@ puts lots\nof\n\n\n\n\n\nnewlines # A word enclosed in braces is not subject to any special interpretation or -# substitutions, except that a backslash before a brace is not counted when look#ing for the closing brace +# substitutions, except that a backslash before a brace is not counted when +# looking for the closing brace set somevar { This is a literal $ sign, and this \} escaped brace remains uninterpreted @@ -163,7 +164,7 @@ set greeting "Hello, $person(name)" # A namespace holds commands and variables namespace eval people { namespace eval person1 { - set name Neo + variable name Neo } } @@ -189,7 +190,10 @@ set greeting "Hello $people::person1::name" namespace delete :: -# Because of name resolution behaviour, it's safer to use the "variable" command to declare or to assign a value to a namespace. +# Because of name resolution behaviour, it's safer to use the "variable" command to +# declare or to assign a value to a namespace. If a variable called "name" already +# exists in the global namespace, using "set" here will assign a value to the global variable +# instead of creating a new variable in the local namespace. namespace eval people { namespace eval person1 { variable name Neo @@ -256,7 +260,7 @@ proc greet greeting\ name return\ \"Hello,\ \$name! proc fold {cmd args} { set res 0 foreach arg $args { - set res [cmd $res $arg] + set res [$cmd $res $arg] } } fold ::tcl::mathop::* 5 3 3 ;# -> 45 |