Re: strange tcl behavior



On Jun 27, 4:06 pm, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
On Jun 27, 2:43 pm, Donald G Porter <d...@xxxxxxxx> 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
.



Relevant Pages

  • Re: How to write output of a tcl script to a file?
    ... File I/O in Tcl, that'd be best. ...    files on disk or sockets or the console or ... ... (puts and gets also take an implicit ... puts $outfile ...
    (comp.lang.tcl)
  • Re: help me understand this code - proc ! args ......
    ... puts "in  ! ...     puts!!$args ... [info level] is the current level and [info level ... $n] is the current function name and args at level $n. ...
    (comp.lang.tcl)
  • Re: optimizing an expression
    ... I hope I never have to code to a standard like this. ...     else { ... allow the puts call to be written once, ...
    (comp.lang.c)
  • Re: The switch "procedure"?
    ...   switch $var { ... To highlight the fact that this "loop" only runs exactly once, ...  if {$var eq a} { ... puts "something went horribly wrong" ...
    (comp.lang.tcl)
  • Re: tcom: cant get builtin document prperties
    ... Ive tried various combinations of puts below and get the following ...     while executing ... set workbooks   ... set builtinproperties   ...
    (comp.lang.tcl)