Overview
| Artifact ID: | 25a7dc9f24ac60f3788aa357b53e6ce3b6e70d19 |
|---|---|
| Ticket: | 3599906fffffffffffffffffffffffffffffffff
dict command has side effects on foreach |
| User & Date: | heinrichmartin on 2013-01-08 08:52:22 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- comment changed to:
"dict keys" takes a dictionaryVALUE, but affects the variable's interpretation by foreach: expect:/tmp$ set tcl_version 8.5 expect:/tmp$ set x {1 a 2 b 3 c 3 d 3 e} ;# store a list which also is a dictionary value 1 a 2 b 3 c 3 d 3 e expect:/tmp$ foreach {key val} $x {puts "$key -> $val"} ;# print pairs of list elements correctly 1 -> a 2 -> b 3 -> c 3 -> d 3 -> e expect:/tmp$ dict keys $x ;# the argument is passed by value, isn't it? (see dict or the dodekalogue) 1 2 3 expect:/tmp$ foreach {key val} $x {puts "$key -> $val"} ;# we had that very command, and x was not altered. 1 -> a 2 -> b 3 -> e expect:/tmp$ set x ;# indeed, x was not altered 1 a 2 b 3 c 3 d 3 e Obviously, variables are stored in best-guess-data-structures (lists, dictionaries, ...) whenever a corresponding command is used. This performance benefit must not affect consistency. Why does foreach treat dict-variables differently? This should not happen, we do have "dict for"! - foundin changed to: "obsolete: 8.5.13"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "heinrichmartin"
- subsystem changed to: "15. Dict Object"
- title changed to: "dict command has side effects on foreach"
- type changed to: "Bug"