Noise word

AMG: Noise words are a kind of syntax sugar.

Noise words don't affect the behavior of a program: Like comments, they're there to enhance readability. Unlike comments, noise words are not entirely ignored: Usually, when a command takes a noise word, it checks the spelling and throws an error if it's not the word it was expecting. Noise words are typically optional, depending on the command.

To test if something's a noise word or not, delete it from the definition of the command and see if any ambiguity is created. If not, it was a noise word.

I don't think it's useful to have a hard-and-fast definition for noise words, since every command is free to be different. So the above definition is more of a guideline.


[if] has two optional noise words: "then" and "else" [1 ]. They can be omitted but they cannot be misspelled. However, "elseif" is required, and I question its status as a noise word. Popular usage of [if] uses "else" but not "then", to match the C programming language and its descendants. (I frequently misspell "elseif" as "else if", which is an error.)

if test1 '''then''' code1 elseif test2 '''then''' code2 '''else''' code3

I'm not aware of any other examples of noise words in the Tcl core. But there are other commands implemented on this Wiki which use noise words.


AMG: Noise words are different than dummy words. Noise words can be only specific values, whereas dummy words can be anything. Also, dummy words affect the program by their presence or absence, whereas noise words do not. Optional noise words are truly optional. For a mandatory noise word to be a noise word, there can only be one possible value, dictated by context. If there's a choice, it's a keyword (correct term?) if the choice makes a difference, or it's a dummy word if the choice doesn't matter.