Array variable name decomposition - kludge leads to bug 
Author Message
 Array variable name decomposition - kludge leads to bug

Hello everybody!

I was having a lot of trouble in my Tcl-linked C++ program due to the fact
that Tcl functions taking variable name as one parameter decompose it "in
place" if variable happens to be array member. As far as I understand it is
done for the sake of efficiency. I don't consider Tcl/Tk to be very
efficient code ( it has nothing to do with my deep gratitude to John
Ousterhout and everybody else who took part in development of mentioned
library ), and this kludge leads to trouble even in plain Tcl/Tk program.

Simple example ( it works with tcl7.3/tk3.6, I believe it works with 7.4,
but I never tried ):

entry .a -textvariable c(a)
entry .b -textvariable c(b)
trace variable c(a) w T
trace variable c(b) w T
proc T { n1 n2 op } { .$n2 configure -bg red }
pack .a .b

Try to enter something at first in one entry, then in another.

Problem here is caused by the fact that trace procedures for textvariables
are called with variable name stored in entry widget structure being
in decomposed state. ConfigureEntry causes variable trace to be destroyed
and then created again, but instead of trace to array member trace to whole
array gets created.

I spent an hour looking for this thing and I consider myself lucky.
I believe that this kludge should be removed from future versions of
library.

Best regards,
Sasha.

--
/-- Alexander V. Panasyuk    | Harvard-Smithsonian Center for Astrophysics  --\

\-- FAX: 617-495-7455        | "No good deed shall remain unpunished."      --/



Sun, 16 Nov 1997 03:00:00 GMT  
 Array variable name decomposition - kludge leads to bug

|> Hello everybody!
|>
|> I was having a lot of trouble in my Tcl-linked C++ program due to the fact
|> that Tcl functions taking variable name as one parameter decompose it "in
|> place" if variable happens to be array member. As far as I understand it is
|> done for the sake of efficiency. I don't consider Tcl/Tk to be very
|> efficient code ( it has nothing to do with my deep gratitude to John
|> Ousterhout and everybody else who took part in development of mentioned
|> library ), and this kludge leads to trouble even in plain Tcl/Tk program.

I agree that this is an undesirable feature.  It's fixed in my sources
now, so once Tk 4.0b4 comes out this will no longer be a problem.



Tue, 18 Nov 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Variable names with a leading digit

2. array name in variable variable

3. how to access arrays with variable for array names and index

4. access to array if name of array is variable

5. HOWTO: reference elements of an array if array name is in a variable

6. How do I use array index to change Boolean(LED) values for 64 LED's

7. Using a variable name for a variable name??

8. More About Array Names In String Variables

9. Q: Variables in associative array names

10. setattr and variable names: bug or feature?

11. tcl 8.0b2 empty named array bug

12. field name and key name as a variable

 

 
Powered by phpBB® Forum Software