Version 2 of '--' in Tcl

Updated 2006-07-20 00:24:53

Several Tcl commands, including expect and switch, take a '--'. RS calls this, "the switch to end all switches". Here's why:

What is the difference between

    switch $variable {...

and

    switch -- $variable {...

? None--mostly; if, however, $variable contains a string such as "-glob", then the first form will be interpreted as

    switch -glob {...

Do you see the problem? Do you see how your datum might be interpreted as a command "switch"? In casual English words, the '--' says, "treat everything that follows like data, not as a 'switch' or 'flag' ..."


Category Syntax