Re: dict traces ...
- From: Neil Madden <nem@xxxxxxxxxxxxx>
- Date: Thu, 07 Feb 2008 14:01:11 +0000
Keith Nash wrote:
I think there is a problem of communication between those who are familiar
with the C implementation of Tcl, and those (like me) who view the
documentation as a set of rules and ask what is logically possible but
without much understanding of the Tcl internals.
set a 1
set b [dict create foo 2 bar 3]
Obviously one cannot trace the value of "1"; but it is possible to trace
reads and writes to a. Equally, one cannot trace the value of "2", but it
is possible to trace reads and writes to b, and if those reads and writes
occur by dictionary commands it is possible to trace whether they occur to
the key "foo". Though it is logically possible it may be at odds with the
way Tcl is implemented.
That is entirely possible. This is simply a regular trace on the variable that filters based on the dict key being accessed. However, you'd have to decide what to do in all the corner cases where the variable is accessed using something other than the dict commands, or changed to be a non-dict value. e.g.:
set foo {a 1 b 2}
dict trace foo a write ...
dict trace foo b unset ...
set foo {a b c}
What happens here? What traces fire (if any)? Is an error generated? Do the traces get removed?
I don't see any of those choices presenting themselves as obviously the correct approach. I also don't see why dicts need to support this functionality, given that we already have arrays and namespaces that support trace-able elements. You can even put a fully-qualified variable name into a dict and trace that.
-- Neil
.
- Follow-Ups:
- Re: dict traces ...
- From: Keith Nash
- Re: dict traces ...
- References:
- dict traces ...
- From: MartinLemburg@Siemens-PLM
- Re: dict traces ...
- From: Alexandre Ferrieux
- Re: dict traces ...
- From: MartinLemburg@Siemens-PLM
- Re: dict traces ...
- From: Keith Nash
- Re: dict traces ...
- From: Joe English
- Re: dict traces ...
- From: Keith Nash
- dict traces ...
- Prev by Date: Re: ttk::treeview tags
- Next by Date: Can't get TCL script-level debugger to work
- Previous by thread: Re: dict traces ...
- Next by thread: Re: dict traces ...
- Index(es):
Relevant Pages
|