On Fri, Nov 20, 2009 at 7:01 PM, William Spitzak <spitzak@...> wrote:
> Ok, sounds reasonable.
> In that case the bug is that libyaml output when told to write a single ""
> scalar, does not write the correct thing, instead writing text that looks
> the same as an empty document.
That sounds like a bug. A YAML processor should not output invalid YAML (or
in this case, valid YAML that means the wrong thing).
> It is true that if you ask for document-start to be written it fixes it but
> there does not seem to be a requirement for that, and in fact I would prefer
> not to as the documents I am writing are so short that the extra 8 bytes are
> a significant fraction.
By 8, you mean 4 ("---\n") + 4 ("...\n")?
If you have more than one document in a stream, then you need "---\n" anyway
for all but the first document. You really don't need "...\n" at all, unless
timing is an issue. If you are writing single document streams to disk, then
certainly you are consuming more space for the inode and file name etc.
I don't know what your exact use case is though. The shortest YAML
serialization for an empty string is 2 single quotes, and libyaml should
support that. (Actually it probably adds a newline as well which is a sane
thing for a general purpose library.)
It has always been the intent of YAML, that a Stream may contain zero or
>> more Documents. This implies that there needs to be a way to serialize zero
>> BTW, a stream containing just comments is another example of something
>> that will parse as having zero documents.
>> It may not be written like this in the spec, but one way to think of it is
>> as follows:
>> 1. Every YAML Document in a YAML Stream begins with '---'.
>> 2. If the first thing a parser sees in a stream, after skipping all
>> ignorable whitespace (including comments), is not '---', nor a
>> YAML directive, the parser should assume it saw "---\n".
>> 3. If, after skipping all ignorable whitespace, the parser reaches
>> the End Of Stream, it should report an STREAM_END event, without
>> reporting any documents.
>> Being able to serialize zero documents is important. For a real use case,
>> imagine a service listening for YAML documents over a web socket. If the
>> socket is closed after receiving no data, the service should *not* parse
>> that as one document containing an empty string.
>> After testing all these cases against libyaml, IMHO it gets things right
>> every time.
>> Cheers, Ingy
>> Bill Spitzak
>> Rhythm & Hues software department.
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> trial. Simplify your report design, integration and deployment - and
>> focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> Yaml-core mailing list
>> Yaml-core@... <mailto: