my_question
my_question

Reputation: 3235

What is wrong with this example in TCL book

I am reading "Tcl/Tk: A developer's guide", in chapter 3.1, it has such bad example:

if {$x > 2} {
     set greater true
}

The book says this code is wrong syntax because "No space between test and body left brace" and will get error message:

Error Message: invalid command name "}"

I tried it in tclsh, it works fine. Also I do not think "{$x" is wrong, "{" is at the start position of a word, so whatever stuff till the matching "}" is enclosed.

Do you see anything wrong?

Upvotes: 0

Views: 63

Answers (1)

Dinesh
Dinesh

Reputation: 16428

In the book, it is given without spaces only.

enter image description here

Running this we will the get the following errors.

% if {$x > 2}{
extra characters after close-brace
%      set greater true
true
% }
invalid command name "}"
%

Upvotes: 1

Related Questions