tcl Expressions Invalid bareword error


Example

In Tcl itself, a string consisting of a single word does not need to be quoted. In the language of expression strings that expr evaluates, all operands must have an identifiable type.

Numeric operands are written without any decoration:

expr {455682 / 1.96e4}

So are boolean constants:

expr {true && !false}

Tcl variable substitution syntax is recognized: the operand will be set to the variable's value:

expr {2 * $alpha}

The same goes for command substitution:

expr {[llength $alpha] > 0}

Operands can also be mathematical function calls, with a comma-separated list of operands within parentheses:

expr {sin($alpha)}

An operand can be a double-quoted or braced string. A double-quoted string will be subject to substitution just like in a command line.

expr {"abc" < {def}}

If an operand isn't one of the above, it is illegal. Since there is no hint that shows what kind of a word it is, expr signals a bareword error.