hi
I'm learning Tcl/Tk and am confused on the usage of curly braces in tcl.
To me it seems to be used to both indicate scope and declare strings! Is this a bug(or feature)?
Is my interpretation correct?
hi
I'm learning Tcl/Tk and am confused on the usage of curly braces in tcl.
To me it seems to be used to both indicate scope and declare strings! Is this a bug(or feature)?
Is my interpretation correct?
curly braces group words together to become arguments. you can find plenty tcl stuffs on the internet by googling. Here's an intro
In a nutshell,
The fact that you use curly braces in a proc
definition is not mandatory. It's just the most convenient way to pass a script as an argument to proc without interpolating.
These are equivalent
proc add3 {a b c} {
return [expr {$a + $b + $c}]
}
and
proc add3_weird [list a b c] "return \[expr {\[set a] + \[set b] + \[set c]}]"
Once you internalize Tcl quoting, you'll realize how truly flexible Tcl can be.
man n Tcl
That is the manual page for the Tcl interpreter! Read it. Read it again! You might even consider to go to a quiet place and read it out loud. This will hinder you from reading too fast. Every single letter counts.
Once you find yourself in "quoting hell" go back to this document and read it again.
There is an online version at: http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm