Artifacts Associated With Ticket 883865ffffffffff
Ticket change [f9e99c889e] (rid 91776) by cnassau on 2004-01-24 22:40:19:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Currently TIP 111 declares that dict get $dictVal $k1 $k2 ... $kn throws an error if $dictVal does not contain a value for the given key sequence. I would suggest to add a switch ?-nocomplain? where "dict get" would simply return an empty string in this case. There is a recent related discussion on the dict page of the Tcl'ers Wiki. There I tried to make the point that there are legitimate use cases where the distinction between a non-existing key and a key with an empty value is deliberately blurred.
- foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "cnassau"
- subsystem initialized to: "16. Commands A-H"
- title initialized to: "Add ?-nocomplain? switch to [dict get]"
- type initialized to: "RFE"
Ticket change [0e0f411a91] (rid 94546) by dkf on 2004-01-27 16:35:32:
- closedate changed to: "2004-01-27T09:35:32"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 No. I (and other Core Team members and Core Maintainers) hate "-nocomplain" options, and there's already a [dict exists] operation to let you create your idea of defaulting getter as a composite operation. For example: proc dictgetwithdefault {dict default key args} { if {[dict exists $dict $key {expand}$args]} { return [dict get $dict $key {expand}$args] } else { return $default } } A separate get-with-default subcommand for [dict] would have more sympathy from me, but only if there is performance data to justify doing it. - login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Rejected"
- status changed to: "Closed"
- subsystem changed to: "15. Dict Object"
- username: "dkf"