02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

B<br />

Tcl<br />

■<br />

■<br />

■<br />

■<br />

Do not put more than one declaration on a line. Each variable and function<br />

argument must be declared on a separate line.<br />

Do not put more than one statement on a line. The only exceptions are:<br />

– Afor statement where the initial, conditional, and loop statements can be<br />

written on a single line:<br />

for {set i 0} {$i < 10} {incr i 3} {<br />

– A switch statement whose actions are short and nearly identical (see the<br />

switch statement format in Indentation, p.332).<br />

The if statement is not an exception. The conditionally executed statement<br />

always goes on a separate line from the conditional expression:<br />

if {$i > $count} {<br />

set i $count<br />

}<br />

Opening braces ({), defining a command body, are always on the same line as<br />

the command itself.<br />

Closing braces (}) and switch patterns always have their own line.<br />

B<br />

Horizontal Spacing<br />

■<br />

Put spaces around binary operators. Put spaces before an open parenthesis,<br />

open brace and open square bracket if it follows a command or assignment<br />

statement. For example:<br />

■<br />

set status [fooGet $foo [expr $i + 3] $value]<br />

if {&value & &mask} {<br />

Line up continuation lines with the part of the preceding line they continue:<br />

set a [expr ($b + $c) * \<br />

($d + $e)]<br />

set status [fooList $foo $a $b $c \<br />

$d $e]<br />

if {($a == $b) && \<br />

($c == $d)} {<br />

...<br />

}<br />

331

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!