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]". Except that that's not it because * Command substitution, variable substitution, and backslash substitution are performed on the characters between the quotes. * No substitutions are performed on the characters between the braces except for backslash-newline substitutions ..., nor do semi-colons, newlines, close brackets, or white space receive any special interpretation. The word will consist of exactly the characters between the outer braces, not including the braces themselves. Both the above are quotes from the [dodekalogue]. ** Discussion ** [EMJ] (2015-04-22) I added the bit about substitution differences, but it's '''not''' discussion, it's essential that something about that is on this page to avoid misleading beginners. Rewrite it if you want but I think it is necessary that it is mentioned here. Moving it under a '''Discussion''' heading is contrary to the spirit of co-operative editing. [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. [dbohdan] 2015-04-22: Sorry about that. I moved your contribution under a new heading because it was clearly a counterargument to the argument put forth in the ''Description''. Just merging it with the description made the text sound strangely self-refuting (a common problem, e.g., [http://c2.com/cgi/wiki%|%WikiWikiWeb]). My initial choice of the heading was probably a poor one but I do think it needs a subsection of its, e.g., ''Criticism'' or ''Counterargument'' (with ''Description'' renamed ''Argument'' in the latter case). ** 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