From: Clark C . Evans <cce@cl...> - 2002-06-02 05:09:10
Ok. More clarity with regard to YAML is emergent
today thanks to Andrew's thoughtful questioning.
YAML serializes a typed and labeled graph which
is both directed and has an origin such that all
nodes in the graph are reachable from the origin.
By typed graph, we mean that each graph is given
a transfer method (a class plus a format). By labeled,
we mean that all branch nodes label their connections
with either integers [sequence] or other nodes [mapping].
By directed with origin, we mean that each document
starts with a top-level node and only nodes reachable
by this top-level node can be serialized. Thus, a structure
such as the one below cannot be serialized:
N1 ---> N2 <--- N3
Where N1 and N3 are "lists" with one item, N2 stored
in their first position and thus having a label of 0.
Note that the above structure doesn't have an origin.
If you start with N1, you will not serialize N3, etc.
In practice, this reachability constraint is not a problem
as all programming languages that I know of have the same
limitation (indeed, unreachable nodes are usually called
"garbage" and are often discarded by a garbage collector).
Also, the above structure can always be represented by
using a convention of introducing a top level node, which,
at the application level is not considered part of the graph.
N1 ---> N2 <--- N3
In Python, the role of the ORIGIN is the top-level namespace
which is a mapping called __dict__. In the example above, it
would have variable names "a" and "b". So, assuming that N2
also has the type "list", this would be represented in Python...
a = []
b = [a]
I hope this is somewhat clarifying the situation; so from
an information model perspective, YAML does indeed have
a few limitations; but those are quite pratical in nature.
From: Steve Howell <showell@ha...> - 2002-06-02 12:09:35
> Ok. More clarity with regard to YAML is emergent
> today thanks to Andrew's thoughtful questioning.
I have posted Clark's thoughts on to the Wiki:
> YAML serializes a typed and labeled graph which
> is both directed and has an origin such that all
> nodes in the graph are reachable from the origin.
Thanks for the explanation.