Forum OpenACS Q&A: Tcl curly braces

Collapse
18: Tcl curly braces (response to 17)
Posted by Andrew Piskorski on
No, the extra braces are not quite superfluous. Yes, Steve is correct that the above example will give exactly the same result regardless of whether you put braces are the argument to the "if" command or not.

But that does not mean that the braces are superfluous. Using the curly braces avoids an extra trip throught the Tcl evaluator.

Collapse
19: Re: Tcl curly braces (response to 18)
Posted by Gustaf Neumann on
andrew, let me add to your argument:
... and with the braces, "if" and "expr" can be byte-compiled and be much faster executed (sometimes an order of magnitude). In earlier versions of Tcl (before 8.0), the braces were indeed not needed, but now they are recommended. Unfortunately, there is still much code in 7.* fashion. If you are interested, here is a script that fixes many of such occurrences in current openacs: http://media.wu-wien.ac.at/download/normalize_expressions.tcl

see as well
http://www.openacs.org/forums/message-view?message_id=335900