From: mark anthony on 14 Jan 2010 06:12 On Jan 13, 3:37 pm, shags72 <je...(a)mtco.com> wrote: > > However, it is not needed as lappend (and append) are documented and defined > > to create the variable if it does not exists. Thus you could just do: > Yes I should be checking listvar, my typing mistake. Avoid info commands if you do not need them, esp if you loop. They are damn expensive. If you know it fails you only once or not that often, constructs like: if {[::catch { something_that_might_fail }]} then { it_failed_so_init_it } are better. In your example you use globals. So instead of info exists checks all over the place, initialize them. cleaner and cheaper. koyama
From: shags72 on 14 Jan 2010 22:54
On Jan 14, 5:12 am, mark anthony <koyam...(a)gmail.com> wrote: > On Jan 13, 3:37 pm, shags72 <je...(a)mtco.com> wrote: > > > > However, it is not needed as lappend (and append) are documented and defined > > > to create the variable if it does not exists. Thus you could just do: > > Yes I should be checking listvar, my typing mistake. > > Avoid info commands if you do not need them, esp if you loop. They are > damn expensive. > > If you know it fails you only once or not that often, constructs like: > > if {[::catch { > something_that_might_fail}]} then { > > it_failed_so_init_it > > } > > are better. > > In your example you use globals. > > So instead of info exists checks all over the place, initialize them. > > cleaner and cheaper. > > koyama What does the :: do for you in front of the catch? I have seen it used for establishing what I consider global but have heard it has something to do with namespace. My version of embedded tcl doesn't support the use of this. It s version 8.1 I think. I haven't gotten a real good answer on this as I tried to use the map option in the string command and it returned map as a bad option. I ended up using regexp and regsub to do my parsing. I felt this was clumsier. Thanks for the tip I will try it and see if it speeds things up. Oh and by the way is there any type of degugger that can be called in as a proc out here on the web? Just thought I would tack this on if possible. If I need to start another thread I will do so. Thanks for the help. |