Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Incompatibility in "trace" parameters

Deleted405084ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2001-03-01 06:46:11
Incompatibility between "trace add variable" and "trace variable".

According to the "trace" manual, "trace variable" is equivelant to 
"trace add variable". But:

1) They don't give the same error messages.
% trace variable
wrong # args: should be "trace variable name ops command"
% trace add variable
wrong # args: should be "trace add variable name opList command"

2) According to the manual, the following should work (and works):
proc tracecall {name1 name2 op} {
  puts "name1=\"$name1\", name2=\"$name2\", op=\"$op\""
}
trace add variable x write tracecall
set x 1

> name1="x", name2="", op="write"

But trying:

trace variable y write tracecall
> bad operations "write": should be one or more of rwua

So, "trace variable" accepts only abbreviations?

3) Finally, the manual info about "trace add variable" is incomplete, since
it does not describe the operation "read" which exists and is referenced 
in the descussion about the parameters passed to the "command" parameter
of the "trace add variable".
petasisplain2001-03-02 13:42:29
Logged In: YES 
user_id=92283

As Jeff Hobbs has pointed, "trace variable" has a different, older
syntax and is deprecated...

> According to the man page, "trace variable" is equivelant to
> "trace add variable" ...

Correct...

> ... and should accept the same parameters, the ones
> described in the man page.

Buzz!  Not correct.  I do not see anywhere in the docs that the same
params are accepted.  It in fact expressly notes in the docs that there
is a distinct mapping:

  These subcommands are deprecated and will likely be removed in a future
  version of Tcl.  They use an older syntax in which array, read, write,
  unset are replaced by a, r, w and u respectively, and the ops argument
  is not a list, but simply a string concatenation of the operations,
  such as rwua.

> ways *do not* accept the same arguments, with "trace variable" being more
> powerful than "trace add variable". Is this a known bug?

'trace add var' is the newer and more powerful syntax, as noted in
the docs.
Log in (anonymous is fine) to add a comment.