From: <in...@tt...> - 2004-02-23 20:01:50
|
On 23/02/04 11:09 +0100, Bra?o Tich? wrote: > I realized null key might be also written > --- > ? : value of nothing > ... > correct? This actually is invalid YAML. When the explicit key indicator '?' is used, the ':' must be on a separate line and in the same column. --- ? : value of nothing ... > but it is IMHO still less clear than explicitly written null. > on the other hand - when will null keys be really used? > AFAIK only python allows None to be key; > perl5 doesn't allow anything but strings, ruby and lua do allow anything - > but null, i don't know about others. > so, python would see None, but everybody else would see something other as > it's own null (perhaps !yaml/null or just !python/None ?) > and would have to cope with it. > am i missing something? The answer you are seeking is a little bit tricky, but is key to understanding the essence of YAML. An empty string is not really a null per se. It is an empty "scalar" that also has an empty "tag". YAML's type repository encourages this combination to be loaded into memory as a Python None or a Ruby null or a Perl undef. But (in the absence of a schema) a YAML loader can load it as anything. In fact, loaders are also encouraged to load all untagged scalars as strings. So how can they be encouraged to do both? It depends on how the application using YAML would like empty values served up. In other words, if there is no "schema" or "contract", two different loaders will probably load the same document in different ways. And this is perfectly OK. It all depends on the application that is using YAML. On the specific use case. You cannot take a random YAML document from Perl, pass it through Ruby, and expect it (beyond a shadow of a doubt) to come back intact. *Unless* there is a schema associated with the document. Or unless the classes in Perl and in Python have been designed to work with each other. Which is really a different form of a "schema" or "contract". Hope this helps. Cheers, Brian |