Overview
| Artifact ID: | 9e91d89e0ad88ebaab1296daf78fae76d2ea937cbcd1451260d87c9b95074b5d |
|---|---|
| Ticket: | 58fa7cc7f88d70c467ccf57fac9dbc532509277f
Callback for unset trace on namespace variable has inexplicable effect on its visibility |
| User & Date: | sebres on 2025-02-20 13:56:01 |
Changes
- closedate changed to: "2460727.08057381"
- closer changed to: "sebres"
- icomment:
This is fully expected behaviour and can be simply explained: Invocation of `variable x` without value in a proc-frame doesn't restore the variable, so after all the unset-trace would not retain it and variable gets deleted hereafter (by the way together with the trace). Basically `variable` without value only creates a link in local proc-frame (scope), which then points to non-existing variable. And if trace leaves the proc callback, this local link gets removed together with the proc-frame. So one has to set variable in trace-callkback (e. g. with `variable x some-val`) then it'd be retained. Otherwise it will be always removed by unset. Even in a NS or global level, `variable x` would not really create a variable, but rather a link to var (which still doesn't exist): ``` % variable x % list [info vars x] [info exists x] x 0 ``` As for the case by repeat, it is also pretty obvious: the unset of variable also removes its trace, so one has to register it again if needed. Here is a code that hopefully explains it: ``` % trace add variable x unset {apply {args {puts "** $args"; variable x}}} % unset -nocomplain x ** x {} unset % list [info vars x] [info exists x] {} 0 % trace add variable x unset {apply {args {puts "** $args"; variable x "restored"}}} % list [info vars x] [info exists x] {} 0 % unset -nocomplain x ** x {} unset % list [info vars x] [info exists x] x 1 ``` Thus closed as invalid. - login: "sebres"
- mimetype: "text/x-markdown"
- resolution changed to: "Invalid"
- status changed to: "Closed"