From: SourceForge.net <no...@so...> - 2009-10-30 10:15:55
|
Bugs item #2889293, was opened at 2009-10-30 05:55 Message generated for change (Comment added) made by msofer You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2889293&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: development: 8.6b1.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Joe Mistachkin (mistachkin) >Assigned to: Donal K. Fellows (dkf) Summary: [info exists array(elem)] deletes array searches Initial Comment: It seems the act of checking for an array element has the effect of deleting pending array searches. Why does INST_EXIST_STK in TEBC call TclObjLookupVarEx with createPart2 non-zero? Example: set s [array startsearch tcl_platform] # # NOTE: Try this test with and without this [puts] line commented. # puts stdout [info exists tcl_platform([clock seconds])]; # improperly invalidates array search. set result [list] while {[array anymore tcl_platform $s]} { if {[array nextelement tcl_platform $s] eq "user"} then { lappend result user } } set result; # should be "user" catch {array donesearch tcl_platform $s} catch {unset -nocomplain result s} ---------------------------------------------------------------------- >Comment By: miguel sofer (msofer) Date: 2009-10-30 08:15 Message: The BC implementation has to mimic exactly the non-compiled implementation. As [info exists] triggers read traces on the array and the traces could well create new elements, the effect on searches is inevitable (or at least very hard to avoid). The comments at the start of TclVarTraceExists attempt an explanation: /* * The choice of "create" flag values is delicate here, and matches the * semantics of GetVar. Things are still not perfect, however, because if * you do "info exists x" you get a varPtr and therefore trigger traces. * However, if you do "info exists x(i)", then you only get a varPtr if x * is already known to be an array. Otherwise you get NULL, and no trace * is triggered. This matches Tcl 7.6 semantics. */ ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2889293&group_id=10894 |