dicttool(3tcl)
π dicttool β Dictionary Tools π
okay bestie, so this is dicttool(3tcl), a manual page from the tcllib crew, and it's genuinely one of my faves because it's just β¨quality of lifeβ¨ for dict. Sit with me, we're gonna go through it together. π«Ά
β¨ NAME β¨
dicttool β Dictionary Tools. that's it, that's the name, short and iconic. π
π SYNOPSIS π
package require Tcl 8.5 9
package require dicttool ?1.2?
ladd varname args
ldelete varname args
dict getnull args
dict print dict
dict is_dict value
rmerge args
so first you need Tcl 8.5 through 9 (yes, both, she's flexible), then you pull in dicttool itself, optionally at version 1.2. then all these little cuties become available. π
πΈ DESCRIPTION πΈ
okay so the whole vibe of dicttool is that it takes the standard dict command you already know and love and goes "what ifβ¦ more". it enhances dict with several brand new commands, and β bonus β it also defines a couple of "creature comfort" list commands, because we deserve comfort. ποΈβ¨
here's the polite part though: every single command in here checks whether a command with the same name already exists before adding itself. so if any of these ever slip into the Tcl core, nobody gets stomped on. considerate. we love to see it. π
π¦ ladd varname args
this one adds a new instance of each element in args to varname, but only if that element isn't already present. no duplicates, no chaos. a no-drama list. β¨
π¦ ldelete varname args
this one deletes all instances of each element in args from varname. every single one. gone. she does not do half measures. π
π¦ dict getnull args
works exactly like dict get, except β and this is the whole point β if the key args doesn't exist, it returns an empty list instead of throwing an error. no tears, no stack trace, just a lil empty list. π
π¦ dict print dict
this produces a string representation of dict where every nested branch gets its own newline, indented by two spaces for every level. it's givingβ¦ readable. finally. π
π¦ dict is_dict value
returns true if value can be interpreted as a dict. and the important bit: it operates in such a way that it does not force an existing dict representation to shimmer into another internal rep. so it checks without disturbing the vibe. no shimmer, no drama. π§
π¦ rmerge args
this returns a dict that's the product of a recursive merge of all the arguments. unlike dict merge, this one descends into all the levels of a dict. π
now listen closely, this part matters: dict keys which end in : indicate a leaf β that means they get interpreted as a literal value, and she will not descend into them any further. okay? okay. π
set items [dict merge {
option {color {default: green}}
} {
option {fruit {default: mango}}
} {
option {color {default: blue} fruit {widget: select values: {mango apple cherry grape}}}
}]
puts [dict print $items]
and that prints the following result:
option {
color {
default: blue
}
fruit {
widget: select
values: {mango apple cherry grape}
}
}
look at that nesting. look at that indentation. she ate. π₯
π BUGS, IDEAS, FEEDBACK π
okay real talk bestie, this document and the package it describes will undoubtedly contain bugs and other problems. that's just how it is. so if you find one, please report it in the category dict of the Tcllib Trackers:
http://core.tcl.tk/tcllib/reportlist
and hey β if you've got ideas for enhancements for either the package and/or the documentation, report those too! we want them!! π«Ά
when proposing code changes, please provide unified diffs, i.e. the output of diff -u. no freestyle, bestie, we need the format.
also, note further that attachments are strongly preferred over inlined patches. you can attach stuff by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. that's the move. π
π KEYWORDS π
dict
π CATEGORY π
Utilities
π COPYRIGHT π
Copyright (c) 2017 Sean Woods <yoda@etoyoc.com>
and that's the whole page, bestie! this one's from tcllib, version 1.2, and it's the dicttool(3tcl) manual β go forth and merge recursively. no cap. πβ¨ππ¦πΈπ«Ά
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2017 Sean Woods <yoda@etoyoc\&.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms