A '''minimal Tcl escaping style''' is a [code style] that eschews unnecessary Tcl escaping syntax. ** Description ** A lot of Tcl code that one encounters employs [Dodekalogue%|%double quotes] even when not strictly necessary. Sometimes this is done to make a text editor highlight those values; other times to make Tcl seem more like [C] or a [Unix] [shell]. Such usage can be confusing to the beginner who is trying to understand the intended use of double quotes, braces, and [Dodekalogue%|%backslash substitution]. Furthermore, the use of these characters can at times have a performance impact that the beginner may find subtle and surprising. The minimal Tcl escaping style presented on this page results in Tcl code that only employs Tcl escape characters where semantically necessary, resulting in code that naturally avoids the pitfalls of extraneous escaping. In some languages such as [C], [Javascript], [Python], double quotes indicate a certain type of value: a string. In Tcl, all values are already strings, so double quotes do not have that function. Instead, they act as syntactic sugar for backslash escaping, providing a much more convenient syntax for words that include whitespace and other special characters. Braces do the same, but are more restricted in what special characters they escape. In summary, double quotes and braces don't do anything backslash can't do, but they're often more convenient. Here are the rules of the minimal escaping style: '''braces''' : Don't use braces where no backslash substitutions are otherwise needed. '''quotes''' : Don't use quotes where braces could be used. That's it. If your code follows this style, you can avoid potential performance issues like `"[[unintended [shimmering]]]"`, as well as whatever miniscule performance improvement that comes from minimizing double quote processing by the Tcl interpreter. This minimal style also "scales" better as one moves into more complex forms of Tcl scripting such as [code generation]. Best of all , beginners will be able to learn by reading your code when braces and quotes are actually needed. It also helps to disabuse them of that all-to-common misunderstanding that braces mean "[list]". For example, if a value contains whitespace, and also [http://wiki.tcl.tk/10259#pagetoc9713972a#pagetoc9713972a%|%substitutions], quotes would be the way to go, since braces would over-escape the value, preventing the substitutions from occurring. [EMJ] 2015-04-30: You can't assume that people will know that something exists, or that they will read pages in the "right" order. Wiki is good at cross-references, we need to use them! ** Discussion ** [EMJ] (2015-04-22) Re "Sometimes this is done..." near the beginning: it might be done to clarify the purpose of a string, or with an eye on a future change (and so is about program maintainability). And I just don't believe the "seem more like [C]" bit. [PYK] 2015-04-30: Anyone who thinks they can improve this page is free to dive in and rewrite it wholesale as far as I'm concerned.... [EMJ] 2015-04-30: No they can't, you'll put their name on the rewrites and try to turn them into another bit of your own private but global edit war! [PYK] 2015-04-30: I added your name to your comments because they were in discussion format, expressing a different opinion. In that case, the speakers need to be labeled so the reader can understand it's different people talking. If you don't want to attribute yourself, you could always defer to ''anonymous coward'' or something. In any case, other readers already aren't going to understand what we're discussing here because the page has already taken on another form. That's cool. It'll just need some cleanup later. ** Examples ** ====== #instead of puts "Hello!" #use puts Hello! ====== ====== #instead of puts "Hello World." #use puts {Hello, World.} ====== ====== #instead of proc {x} { ... } #use proc x { ... } ====== ** See also ** * [A question of style] <> Code Style | Tcl Quoting