Overview
| Artifact ID: | 61732824163d445294b7c17a81d4807e94c6429f |
|---|---|
| Ticket: | 3057639fffffffffffffffffffffffffffffffff
lappend inconsistency with respect to read traces |
| User & Date: | andreas_kupries on 2010-09-02 00:46:01 |
Changes
- icomment:
Notes from the discussion of the problem ... ================================== [JH] There is a related set of comments in append.test around this behavior change: # The behavior of read triggers on lappend changed in 8.0 to # not trigger them, and was changed back in 8.4. This of course adversely effects ::env, which has a built-in read trace that errors on unknown vars. So why does the first case not error in 8.4? Apparently the fix to lappend only kicked in for the fully byte-compiled case. That means placing it straight in a proc, or in an if/else you would see the change, but 'switch' wasn't byte-compiled until 8.5. At this point, I don't know what the best resolution is. The intention of the change was to allow read traces to trigger with lappend. ::env has a read trigger that errors on unknown variable reads. This was new in 8.4, but again masked by code that didn't use the byte-compiled version. ================================== [HL] Hi Jeff, I have modified your example bit more ... The test1 passes in tcl8.5 but test2 fails. It seems that the behavior changes whether -- switch is specified after -exact or not. If I do not specify the -exact switch, then it fails for both in tcl8.5. So the "--" option seems to be changing its behavior. Ok, assuming that this is the intended behavior -- what about regular array variables? Shouldn't it behave the same if I define a read trace on global array x with no elements defined for it but use lappend to add value to it. proc test {var oper elem value} { switch -exact -- $oper { add { lappend [set var]($elem) $value } } } proc foo args {puts $args} trace add variable ::x read foo test ::x add key "new value" test ::env add key "new value" It doesn't seem to throw any error for other tcl variables. So why is only ::env variable treated specially. - login: "andreas_kupries"
- mimetype: "text/plain"
- username: "andreas_kupries"