Re: Next YAML: drop equality definition
Osamu TAKEUCHI <[email protected]> Tue, 8 Mar 2016 13:25:55 +0900
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
Oren,
> I missed to state the point clearly.
> See the next example:
>
> ? !element '<a href="index.html">Top</a>'
> : insert it before #the-box in red
> ? !element '<a href="index.html">Top</a>'
> : insert it after #the-box in blue
>
>
> If we allow this thing then we need to require all processors
>to keep track of it and provide some API to distinguish between
>these two entries. We explicitly and intentionally do _not_ r
>equire YAML processors to do this. Among other reasons, this gives
>implementation greater freedom to use simpler APIs and more efficient
>internal data structures, such as using actual native hash tables -
>even for the intermediate partial representations.
>
> Therefore, this document is not safe. Passing it through some tools
>will cause data to disappear, or processing to fail. So it is _not_
>valid YAML.
I still think they should.
I give another example.
How do you read the next document?
- !div
- !textNode "Hello! "
- !textNode "Hello! "
I expect two text nodes are inserted in a div.
> var d = document.createElement('div');
> var t1 = document.createTextNode('Hello! ');
> var t2 = document.createTextNode('Hello! ');
> d.appendChild(t1);
> d.appendChild(t2);
> document.body.appendChild(d);
Current spec allow YAML processor to generate only one !textNode
from the file and insert it twice into the div. Namely, the spec
allows a processor to treat the above file as if the next file is
given.
- !div
- &T !textNode "Hello! "
- *T
> var d = document.createElement('div');
> var t = document.createTextNode('Hello! ');
> d.appendChild(t);
> d.appendChild(t);
> document.body.appendChild(d);
On the contrary the next works fine under the current spec
because the identity of collection nodes are always preserved.
- !div
- !textNode text: "Hello! "
- !textNode text: "Hello! "
I believe this surprises users.
YAML processors should only be allowed to discard the identities
of scalars _with standard tags_ but not those _with custom tags_.
How the equality and identity are evaluated for a specific data
must be determined by tags.
Actually, I don't see how a YAML library can _unintentionally_
discard identities of scalar nodes with custom tags. Could you
show an example?
Osamu Takeuchi
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://makebettercode.com/inteldaal-eval