Artifacts Associated With Ticket 7f02ff1efa
Ticket change [e25e31d139] (rid 148662) by dgp on 2016-09-07 17:06:01:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
proc constant {name value} { upvar 1 $name c set c $value trace variable c wu [list reset $value] } proc reset {v a i o} { uplevel 1 [list constant $a $v] } proc demo {} { puts [info exists pi] constant pi 3.14 puts [info exists pi] } puts [info exists pi] demo puts [info exists pi] Output is: 0 0 1 1 Output should be: 0 0 1 0 The unset trace that re-creates the variable is doing so in the caller context of [demo]. This is wrong. - is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "07. Variables"
- title initialized to: "unset traces on local vars write in caller context"
- type initialized to: "Bug"
Ticket change [ca6e556bfb] (rid 148663) by dgp on 2016-09-07 17:17:34:
- icomment:
The same flaw is present on core-8-0-3-pr which suggests it is in all of recorded Tcl history.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [08b02bc652] (rid 148664) by dgp on 2016-09-07 17:22:14:
- icomment:
I have a binary of tclsh 7.5p1 which exhibits the same flaw. This raises the concern that this has been wrong for so long, there may well be scripts relying on the bug. Very old, unmaintained scripts. Suggest we fix only in 8.7+, at least at first.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [a208dc2e4d] (rid 148675) by dgp on 2016-09-07 18:32:53:
- icomment:
See branch bug-7f02ff1efa. Test trace-18.1 fails. Suspect the test is wrong.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [36016d22bc] (rid 148682) by dgp on 2016-09-08 02:39:23:
- assignee changed to: "dgp"
- closedate changed to: "2457639.61068788"
- closer changed to: "dgp"
- icomment:
Fixed and tested in 8.7.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [15623a5148] (rid 148744) by apnadkarni on 2016-09-09 06:16:17:
- closedate changed to: "2457640.76131311"
- closer changed to: "apnadkarni"
- icomment:
Note that the documentation currently states: "If an unset occurs because of a procedure return, then the trace will be invoked in the variable context of the procedure being returned to:" So although the exhibited behaviour may not be desirable, it is what is documented.
- login: "apnadkarni"
- mimetype: "text/plain"
Ticket change [1e9bb880f5] (rid 148749) by dgp on 2016-09-09 12:22:59:
- closer changed to: "nobody"
- icomment:
So it is. That documentation is also as old as recorded Tcl history. The design seems unusably broken if you ask me. It forces you to write a handler script that functions correctly in 2 completely different contexts. I'll revert the change from the trunk (8.7). For now, I plan to leave it in novem. At least this wart should be removed in Tcl 9, IMHO, if not a more complete reworking of traces altogether. Experience shows me that a programmatic unset of a variable is meaningfully different from the destruction of a variable (say, because context or interp are going away), and the trace mechanism ought to be able to react to that difference.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Remind"
- status changed to: "Open"
- type changed to: "RFE"
Ticket change [58ddbd715e] (rid 148757) by apnadkarni on 2016-09-09 12:57:20:
- icomment:
Personally, I would not have any heartburn if it was fixed for 8.7. Difficult for me to imagine any code that relied on this behaviour. But then again my imagination doesn't go too far.
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [1320d34006] (rid 149149) by dkf on 2016-10-09 16:35:59:
- icomment:
I'd like to totally remove traces on local variables from novem. The semantics are really expensive to implement and deeply confusing. However, I'd need to replace with an ability to get callbacks when a frame terminates (that <b>is</b> useful) and having the ability to designate variables as being unable to change after the initial setup is entirely reasonable too. FWIW, <i>tclquadcode</i> is never going to be exactly reproducing of the trace-level view. The most we're likely to promise is that if a global variable would have been read from or written to at least once on some path between two suspension points (e.g., entries and calls to <tt>return</tt> or <tt>yield</tt>), a trace will be fired. That's really quite different to getting the semantics right, and gives us a lot more freedom to optimise.
- login: "dkf"
- mimetype: "text/x-fossil-wiki"
- username: "dkf"
- icomment:
Ticket change [f94231d3ae] (rid 149574) by gustafn2 on 2016-11-16 08:59:32:
- icomment:
unset traces on local variables are a nice means for firing handlers when local scopes are left. we are using this in some places for the automatic cleanup of local objects, when a proc scope is left. Maybe this behavior could be moved with some tweaking into command leave traces. However, the trace handler has no access to the local vars of the left proc, so one has to record the information about the objects which should be deleted somewhere else. E.g. defining on-shot handlers for every proc invocation seems expensive, global vars are not pretty, ...
- login: "gustafn2"
- mimetype: "text/plain"
- icomment:
Ticket change [b2ec068c9c] (rid 163733) by dgp on 2018-06-01 17:55:46:
- icomment:
test trace-18.5 is failing again on novem. Time to consider how we handle this issue again.
- login: "dgp"
- mimetype: "text/plain"
- icomment: