piper
piper

Reputation: 87

How to check if a proc has syntax errors before executing it in tclsh

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

Answers (1)

Related Questions