From: SourceForge.net <no...@so...> - 2010-09-01 17:46:01
|
Bugs item #3057639, was opened at 2010-09-01 10:41 Message generated for change (Comment added) made by andreas_kupries You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3057639&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 17. Commands I-L Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Andreas Kupries (andreas_kupries) Assigned to: Andreas Kupries (andreas_kupries) Summary: lappend inconsistency with respect to read traces Initial Comment: A problem was found with lappend using read traces on arrays inconsistently in the bytecompiled and direct evaluation code paths. Attached code demonstrating the issue. ---------------------------------------------------------------------- >Comment By: Andreas Kupries (andreas_kupries) Date: 2010-09-01 10:46 Message: 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. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3057639&group_id=10894 |