| Ticket UUID: | 433252 | ||
| Title: | Better coherence in traces | ||
| Type: | RFE | Created on: | 2001-06-14 21:44:52 |
| Submitter: | msofer | Assigned to: | dgp |
| Subsystem: | 46. Traces | Severity: | |
| Priority: | 5 Medium | Last modified: | 2003-06-27 15:27:38 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | None | ||
| Description: | ||||
The rule for when a read trace fires seem capricious:
consider
trace variable x r {puts hello;#}
* [append x 1] does not fire (even if x is a pure list)
* [append x {}] does not fire
* [append x] fires
* [lappend x 1] fires (even if x is a pure list)
* [lappend x] fires
| ||||
| User Comments: | ||||
msofer added on 2001-06-15 05:00:22:
Logged In: YES user_id=148712 Forgot one: [info exists x] does not really read the value, but the read trace is fired ... fbonnet added on 2001-06-18 14:39:51:
Logged In: YES user_id=93873 both append and lappend eventually return the value of the variable, so they should both fire a read event whatever the arguments welch added on 2001-06-21 11:02:48:
Logged In: YES user_id=89720 The reason that "info exist" fires a read trace is so you can simulate variables that don't really exist, or that require fabrication on the fly. In particular, this change was made to support variables shared among different Tcl interpreters running in different threads. I can't speak to the quirkiness of append vs. lappend, except to speculate that it is a performance optimization. nobody added on 2001-06-23 00:01:11:
Logged In: NO It wasn't the best design decision to allow traces on non-existant variables, but here we are. Most programmers expect "info exists varName" to be non-invasive. This was changed and then changed back to the current behavior. As far as traces firing or not firing on append or lappend operations, it probably doesn't matter. I can't think of a situation where I would want to put a read trace on a variable I was appending to. I might put a write trace to make it read-only. I might put a read trace to simply supersede it's current value. trace variable date r ResetDate I'm guessing that's why nobody ever's complained about the inconsistency before. dkf added on 2003-06-27 15:27:38:
Logged In: YES user_id=79902 You might want a trace on a variable you append to if the variable value was something that was somehow shared between interpreters that communicate across, say, a network connection. Debugging is another obvious application. | ||||
