From b990f84123a755b8aa36db3667a59b7d774daad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Tue, 25 Aug 2015 12:29:44 +0200 Subject: Fix broken line-change in TCL docs. --- tcl.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100755 => 100644 tcl.html.markdown (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown old mode 100755 new mode 100644 index 198f675e..79b5e87d --- 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 -- cgit v1.2.3 From 9650cdc12468e91cb7a64aad6017671b7a40c1ef Mon Sep 17 00:00:00 2001 From: "Q. Zero Lee" Date: Tue, 25 Aug 2015 22:41:22 +0800 Subject: Added a dollar --- tcl.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown index 79b5e87d..c1cd42ca 100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -257,7 +257,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 -- cgit v1.2.3 From 7d2339328d5bb2b0bd642809cd68a604d7d2a34d Mon Sep 17 00:00:00 2001 From: Alexander Farley Date: Wed, 26 Aug 2015 16:47:21 -0400 Subject: Updating line 167 to fix name resolution error at line 73. Also, elaborated on name resolution with set vs. variable. --- tcl.html.markdown | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown index c1cd42ca..9ca32f1e 100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -164,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 } } @@ -190,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 -- cgit v1.2.3 From 0963dbaba3ff808e13cc33178434633533f3105e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Tue, 1 Sep 2015 14:44:46 +0200 Subject: Tcl. Fix mid-page rendering error Github's syntax-highlighting has an error in the Tcl syntax-parser causing the rendering of the page to fail about one third in. This commit bypasses this rendering-error by resetting the syntax highlighting after the error has occurred. --- tcl.html.markdown | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown index 9ca32f1e..af2911c9 100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -149,6 +149,9 @@ set greeting "Hello, [set {first name}]" # To promote the words within a word to individual words of the current # command, use the expansion operator, "{*}". +``` + +```tcl set {*}{name Neo} # is equivalent to -- cgit v1.2.3 From 57ad6d412d829be6ebedfffaf0ea16341cc12cd1 Mon Sep 17 00:00:00 2001 From: Tim Heaney Date: Mon, 5 Oct 2015 22:46:03 -0400 Subject: Typo: "too many" rather than "to many" --- tcl.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown index af2911c9..3982807f 100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -356,7 +356,7 @@ eval $command ;# There is an error here, because there are too many arguments \ set replacement {Archibald Sorbisol} set command {set name $replacement} set command [subst $command] -eval $command ;# The same error as before: to many arguments to "set" in \ +eval $command ;# The same error as before: too many arguments to "set" in \ {set name Archibald Sorbisol} -- cgit v1.2.3 From 960ee4a1856db8eadb96277bb2422edfa8f2a81c Mon Sep 17 00:00:00 2001 From: Gabriel Halley Date: Wed, 7 Oct 2015 23:11:24 -0400 Subject: removing whitespace all over --- tcl.html.markdown | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown index 3982807f..b90bd690 100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -14,7 +14,7 @@ programming language. It can also be used as a portable C library, even in cases where no scripting capability is needed, as it provides data structures such as dynamic strings, lists, and hash tables. The C library also provides portable functionality for loading dynamic libraries, string formatting and -code conversion, filesystem operations, network operations, and more. +code conversion, filesystem operations, network operations, and more. Various features of Tcl stand out: * Convenient cross-platform networking API @@ -58,14 +58,14 @@ lighter that that of Lisp, just gets out of the way. #! /bin/env tclsh ################################################################################ -## 1. Guidelines +## 1. Guidelines ################################################################################ # Tcl is not Bash or C! This needs to be said because standard shell quoting # habits almost work in Tcl and it is common for people to pick up Tcl and try # to get by with syntax they know from another language. It works at first, # but soon leads to frustration with more complex scripts. - + # Braces are just a quoting mechanism, not a code block constructor or a list # constructor. Tcl doesn't have either of those things. Braces are used, # though, to escape special characters in procedure bodies and in strings that @@ -73,7 +73,7 @@ lighter that that of Lisp, just gets out of the way. ################################################################################ -## 2. Syntax +## 2. Syntax ################################################################################ # Every line is a command. The first word is the name of the command, and @@ -83,13 +83,13 @@ lighter that that of Lisp, just gets out of the way. # are used, they are not a string constructor, but just another escaping # character. -set greeting1 Sal +set greeting1 Sal set greeting2 ut set greeting3 ations #semicolon also delimits commands -set greeting1 Sal; set greeting2 ut; set greeting3 ations +set greeting1 Sal; set greeting2 ut; set greeting3 ations # Dollar sign introduces variable substitution @@ -126,11 +126,11 @@ puts lots\nof\n\n\n\n\n\nnewlines set somevar { This is a literal $ sign, and this \} escaped brace remains uninterpreted -} +} # In a word enclosed in double quotes, whitespace characters lose their special -# meaning +# meaning set name Neo set greeting "Hello, $name" @@ -178,7 +178,7 @@ set greeting "Hello $people::person1::name" ################################################################################ -## 3. A Few Notes +## 3. A Few Notes ################################################################################ # All other functionality is implemented via commands. From this point on, @@ -193,8 +193,8 @@ 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. If a variable called "name" already +# 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 { @@ -210,7 +210,7 @@ set people::person1::name Neo ################################################################################ -## 4. Commands +## 4. Commands ################################################################################ # Math can be done with the "expr" command. @@ -295,7 +295,7 @@ while {$i < 10} { # A list is a specially-formatted string. In the simple case, whitespace is sufficient to delimit values -set amounts 10\ 33\ 18 +set amounts 10\ 33\ 18 set amount [lindex $amounts 1] @@ -339,7 +339,7 @@ eval {set name Neo} eval [list set greeting "Hello, $name"] -# Therefore, when using "eval", use [list] to build up a desired command +# Therefore, when using "eval", use [list] to build up a desired command set command {set name} lappend command {Archibald Sorbisol} eval $command @@ -355,7 +355,7 @@ eval $command ;# There is an error here, because there are too many arguments \ # This mistake can easily occur with the "subst" command. set replacement {Archibald Sorbisol} set command {set name $replacement} -set command [subst $command] +set command [subst $command] eval $command ;# The same error as before: too many arguments to "set" in \ {set name Archibald Sorbisol} @@ -364,12 +364,12 @@ eval $command ;# The same error as before: too many arguments to "set" in \ # command. set replacement [list {Archibald Sorbisol}] set command {set name $replacement} -set command [subst $command] +set command [subst $command] eval $command # It is extremely common to see the "list" command being used to properly -# format values that are substituted into Tcl script templates. There are +# format values that are substituted into Tcl script templates. There are # several examples of this, below. @@ -422,12 +422,12 @@ proc while {condition script} { # The "coroutine" command creates a separate call stack, along with a command # to enter that call stack. The "yield" command suspends execution in that -# stack. +# stack. proc countdown {} { #send something back to the initial "coroutine" command yield - set count 3 + set count 3 while {$count > 1} { yield [incr count -1] } @@ -435,12 +435,12 @@ proc countdown {} { } coroutine countdown1 countdown coroutine countdown2 countdown -puts [countdown 1] ;# -> 2 -puts [countdown 2] ;# -> 2 -puts [countdown 1] ;# -> 1 -puts [countdown 1] ;# -> 0 +puts [countdown 1] ;# -> 2 +puts [countdown 2] ;# -> 2 +puts [countdown 1] ;# -> 1 +puts [countdown 1] ;# -> 0 puts [coundown 1] ;# -> invalid command name "countdown1" -puts [countdown 2] ;# -> 1 +puts [countdown 2] ;# -> 1 ``` -- cgit v1.2.3