I'm currently writing a Tcl-based tool for symbolic matrix manipulation, but the code is getting slow. I'm looking for ways to accelerate my Tcl code (Tcl version 8.6).
I have one suspicion. My code builds lists with a command name as the first element and command arguments as the following elements (this comes from emulating an object-oriented approach). I use eval to invoke these commands (and this is done often in the recursive processing). I read at https://wiki.tcl-lang.org/page/eval and https://wiki.tcl-lang.org/page/Tcl+Performance that eval may be slow.
I have three questions:
What would be the fastest way to invoke a command from a list with command name and parameters which is constructed just beforehand?
Would it accelerate the code to separate the command name
myCmdand the parameter listmyParand invoke the command with[$myCmd {*}$myPar]instead (suggested at https://stackoverflow.com/a/27619692/3852630)?Is the trick with
if 1instead ofevalstill promising in 8.6?
Thanks a lot for your help!
set cmd [list mycmd arg1 arg2 ...]then you can invoke it with just{*}$cmd. - glenn jackman$someVar[set someVar {}]construction: What is it doing? Appending{}to the value ofsomeVar? - Ralf