A '''deep [dict%|%dictionary]''' is a dictionary in which each value is [deep
list]: Each key has the
same representation it would have in a standard [dict%|%dictionary],
and each
value is a [deep listher]: a It is eimplther value nother a deep dictionary. or A simple
value
, which is represented as a list containing only one item. Because it is
often useful to assign multiple values to an entry, that one item is itself a
list of values.
** See Also **
[scripted dict]: Scripting a deep dict in a manner similar to [scripted list].
** Description **
** Implementations **
[ycl%|%ycl dict deep]: Provides `get`, `merge`, `pretty`, and `set`.
** Description **
Another way to define deep dictionary is as a [deep list] that represents a
[tree]: Each value, is a branch that and may or may not have subordinate
branches.
A '''deep dictionary''' can be unambiguously merged into another deep
dictionary.
The key benefit of a deep dictionary is that the structure is self-describing:
In contrast with a standard [dict%|%dictionary], it is possible to determine
whether a value is a leaf node or an intermediate node. A value that is a list
with more than one item is additional structure, whereas a value that is a list
with only one item does not.
Unlike a standard Tcl dictionary, a '''deep dictionary''' is suitable for
communicating an ordered tree without prior agreement between the parties aboutthe exact shape of the tree. A '''deep dictionary''' can be unambiguously
merged into another deep dictionary.
'''Example''':
======
{key 1} {{
{value 1}
{value 2}
}}
{key 2} {
{key 2a} {{{value 3}}}
{key 2b} {{
{value 4}
{value 5}
}}
}
======
<<categories>> deep list