|
Prev: Devanagari question
Next: Tcl Jobs and Degrees
From: IonutAnghelcovici on 27 Jun 2008 05:01 Hello everybody! I have a big problem with a TCL script. I will do my best to describe the behavior: I have a C program that defines some custom TCL commands. The program parses an input TCL file. When it starts the parsing the only custom command is defobj <name> <alias>. What that command does is to create two new commands: "name" and an alias to it called "alias". The startup script does the following: if { [info commands "custom_command"] == "" } { source prim_script.tcl } The prim_script.tcl is: set test_var custom_command .... if { $test_var == "custom_command" } { { puts $test_var defobj custom_command custom_alias puts $test_var } ...... When I run the script I get the following output: custom_command custom_alias The crazy thing is that if I change the startup script to: puts [info commands "custom_command"] == "" } { source prim_script.tcl } Can somebody help me understand why the value of test_var is changed to cusom_alias ? Thank you, Ionut Anghelcovici
From: Donald G Porter on 27 Jun 2008 08:43 IonutAnghelcovici wrote: > When it starts the parsing the only custom command is defobj <name> > <alias>. What that command does is to create two new commands: "name" > and an alias to it called "alias". > puts $test_var > defobj custom_command custom_alias > puts $test_var > When I run the script I get the following output: > custom_command > custom_alias > Can somebody help me understand why the value of test_var is changed > to cusom_alias ? It's hard to be sure, but the results suggest that the [defobj] command may not be properly respecting the Copy-On-Write rules for modifying Tcl values. Is the implementation of [defobj] available for review? -- | Don Porter Mathematical and Computational Sciences Division | | donald.porter(a)nist.gov Information Technology Laboratory | | http://math.nist.gov/~DPorter/ NIST | |______________________________________________________________________|
From: Alexandre Ferrieux on 27 Jun 2008 09:06 On Jun 27, 2:43 pm, Donald G Porter <d...(a)nist.gov> wrote: > IonutAnghelcovici wrote: > > When it starts the parsing the only custom command is defobj <name> > > <alias>. What that command does is to create two new commands: "name" > > and an alias to it called "alias". > > puts $test_var > > defobj custom_command custom_alias > > puts $test_var > > When I run the script I get the following output: > > custom_command > > custom_alias > > Can somebody help me understand why the value of test_var is changed > > to cusom_alias ? > > It's hard to be sure, but the results suggest that the [defobj] > command may not be properly respecting the Copy-On-Write rules for > modifyingTclvalues. > > Is the implementation of [defobj] available for review? I've found http://ftp.swarm.org/pub/swarm/src/swarm/swarm-2.2.tar.gz Apart from the programming langauge being objc, one striking thing is that it seems to be using the old argc/argc command interface (Tcl_CreateCommand). To violate COW in this case, the code must be casting over a "const char *", but I have not yet homed in on the spot. -Alex
From: IonutAnghelcovici on 27 Jun 2008 10:35 On Jun 27, 4:06 pm, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote: > On Jun 27, 2:43 pm, Donald G Porter <d...(a)nist.gov> wrote: > > > > > IonutAnghelcovici wrote: > > > When it starts the parsing the only custom command is defobj <name> > > > <alias>. What that command does is to create two new commands: "name" > > > and an alias to it called "alias". > > > puts $test_var > > > defobj custom_command custom_alias > > > puts $test_var > > > When I run the script I get the following output: > > > custom_command > > > custom_alias > > > Can somebody help me understand why the value of test_var is changed > > > to cusom_alias ? > > > It's hard to be sure, but the results suggest that the [defobj] > > command may not be properly respecting the Copy-On-Write rules for > > modifyingTclvalues. > > > Is the implementation of [defobj] available for review? > > I've foundhttp://ftp.swarm.org/pub/swarm/src/swarm/swarm-2.2.tar.gz > Apart from the programming langauge being objc, one striking thing is > that it seems to be using the old argc/argc command interface > (Tcl_CreateCommand). To violate COW in this case, the code must be > casting over a "const char *", but I have not yet homed in on the > spot. > > -Alex Hello guys and thank you for the quick response! You are both right. I was using the old command interface and, playing with some pointers there, I didn't see that I was overwriting the value of one of the argv[]. After fixing that it works perfectly. Thank you again, Ionut
|
Pages: 1 Prev: Devanagari question Next: Tcl Jobs and Degrees |