I am having difficulty using the Tcl trace command without Komodo Edit reporting a syntax error on what seems perfectly good code.
As an example :-
# -------------------- #
set vTrace 0
proc pTrace {} {
}
trace add variable vTrace write pTrace
# -------------------- #
This gives the error "Undefined procedure: pTrace"
Clearly untrue.
Can you please tell me what is wrong?
What is giving you that error? I do not see that issue with ActiveTcl 8.5. Instead you have incorrectly defined pTrace as a trace proc, as it should take some arguments.
This is an example taken from your own Tcl documentation :-
proc doMult args {
global foo bar foobar
set foobar [expr {$foo * $bar}]
}
trace add variable foo write doMult
trace add variable bar write doMult
When I enter this into Komodo edit 4.4, I get a wavy green line under the doMult word of 'trace add variable foo write doMult' indicating a code warning.
When I place the cursor over this word, I get the status bar warning message 'undefined procedure: doMult'
If I comment out the line, the warning moves to the next incidence. ie. in the line 'trace add variable bar write doMult'
Contrary to the code warnings, it seems clear to me that the procedure doMult does indeed exist.
This is of course with the seperately supplied Tcl linter installed.
Hi arfer.
In general, Komodo runs the Tcl linter in -onepass mode, where a number of things are not done to gain speed, at the cost of accuracy. I.e. the regular checker runs twice over the code, picking up definitions first, then doing the regular check. Whereas in -onepass only the check.
That said, in the example above it does make sense that the linter should know 'doMult' at the the 'trace add' command is checked, given that the procedure was defined lexically before them. I.e. it should at least pick up the definitions in the check pass for use in checking the code coming afterward.
As such I would classify this as a bug and ask you to file a report into ActiveState's bug tracker at http://bugs.activestate.com/.