Reputation: 87
I have defined a proc in tclsh
proc abs {x} {
if {$x > 0} {
puts "111"
} else if {$x = 0} {
puts "222"
} else {
puts "333
}
}
When defining this proc, tclsh did not detect my syntax error until it was reported during execution.
tclsh8.5 % abs 1
wrong # args: extra words after "else" clause in "if" command
while evaluating {abs 1}
How to check the syntax of this proc before executing it?
Upvotes: 1
Views: 90
Reputation: 4382
One tool to detect syntax errors in Tcl scripts is https://nagelfar.sourceforge.net/
Some others are listed at https://wiki.tcl-lang.org/page/Static+syntax+analysis#95329c336da897c3dea8ab434ca30575f4529bf6f514c1519881bd126e1d1423
Upvotes: 2