Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 803b1e8f2c6caded8561f3c25d2842fddc2cf8ae
Ticket: 2929546fffffffffffffffffffffffffffffffff
"dict with" binds to varibles outside its scope
User & Date: johannes-kuhn on 2010-01-11 23:04:43
Changes

  1. icomment:
    dict with works as follows:
    it sets for each key a variable with the name of the key and the value in the same scope, and safes a list of variables that exist at this point.
    After execution of the body it writes all changed variables that correspond to a key and new variables back to the dict.
    
    A side-effect of this is that all variables with a corresponding key are overwritten.
    e.g
    % set a A
    % dict set x a 1
    % dict with x {}
    % set a
    would return 1
    
    This affects all Versions of Tcl 8.5 and Tcl 8.6 and is documented.
    
    Other example:
    set b(1) 2
    dict set x b 3
    dict with x {}
    -> can't set "b": variable is array
    
    Imho this isn't a bug. It's a feature.
    
    Tip: use apply and upvar to avoid this.
    
    
  2. login: "johannes-kuhn"
  3. mimetype: "text/plain"
  4. username: "johannes-kuhn"