Overview
| Artifact ID: | 0c0ca53d9253bb4ce555e985dec9a9b98c225cd2 |
|---|---|
| Ticket: | 1b0266d8bbc649bcb4df5dc4a1edca238536262b
Single-argument [dict merge/remove/replace] |
| User & Date: | andy on 2014-05-21 22:58:03 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
When given only one argument, [dict remove] and [dict replace] seem to return that argument without even looking at it. Consequently, they can be made to return non-dicts (i.e. invalid list or odd list length) and noncanonical dicts (i.e. with duplicate keys). When given only one argument, [dict merge] forces the argument to be a dict (thereby rejecting non-lists and odd-length lists), but the string representation is preserved. Consequently, [dict merge] can be made to return noncanonical dicts. % dict remove \{\}x {}x % dict remove {a 1 b} a 1 b % dict remove {a 1 b 2 a 3} a 1 b 2 a 3 % dict replace \{\}x {}x % dict replace {a 1 b} a 1 b % dict replace {a 1 b 2 a 3} a 1 b 2 a 3 % dict merge \{\}x list element in braces followed by "x" instead of space % dict merge {a 1 b} missing value to go with key % dict merge {a 1 b 2 a 3} a 1 b 2 a 3 % ::tcl::unsupported::representation [dict merge {a 1 b 2}] value is a dict with a refcount of 3, object pointer at 0xbeb3b0, internal representation 0xbe11a0:0xbeb860, string representation "a 1 b 2" % ::tcl::unsupported::representation [dict merge {a 1 b 2 a 3}] value is a dict with a refcount of 5, object pointer at 0x1c3a560, internal representation 0x1c843a0:0x1c35790, string representation "a 1 b 2 a 3" Contrast with every other [dict] command that returns a dict and/or sets a dict variable. They all produce only canonical dicts. % dict get {a 1 b 2 a 3} a 3 b 2 % ::tcl::unsupported::representation [dict get {a 1 b 2 a 3}] value is a list with a refcount of 1, object pointer at 0x99cc90, internal representation 0x9adb00:(nil), no string representation % ::tcl::unsupported::representation [dict get {a 1 b 2}] value is a list with a refcount of 1, object pointer at 0x9a09e0, internal representation 0x9db0e0:(nil), no string representation - foundin changed to: "cdc4e05235717e4959d745e4cc6670bd1333c783"
- is_private changed to: "0"
- login: "andy"
- priority changed to: "5 Medium"
- private_contact changed to: "662c23482b0bf6a505f39e48fb7ad43af8dee4d3"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "andy"
- subsystem changed to: "15. Dict Object"
- title changed to: "Single-argument [dict merge/remove/replace]"
- type changed to: "Bug"