Re: yaml-cpp and YAML 1.2

Andrey Somov <[email protected]> Fri, 4 Mar 2016 09:17:32 +0100
Newsgroups gmane.text.yaml.general
Message-ID <CALbkv0c3-hqmB++Bw3j2=9k0GCpoJyYpDZMcgSgv9_h7JioQ=g@mail.gmail.com>
I am also confused now.
(I think it better to clarify what is "tag resolution schema" outside of
this thread, because it is important for everyone, not only yaml-cpp.)

1. At the moment PyYAML and SnakeYAML give users a possibility to use a
custom Resolver for the tag resolution.
Does it mean that they are YAML 1.2 compliant ?
- the schema must be still implemented by users (regular expressions must
match the YAML 1.2 expectations)
- if users of the same parser want to exchange documents they have to send
_code_ , otherwise the same configurations will be parsed differently. The
spec says that 3 schemas should be implemented as an option which would
mean that a user may give a YAML file to another user and simply say
"please parse with this schema" (all the required code is already inside
the parser).

2.
>Providing a YAML::Node load_complete_representation("foo.yaml",
tag_resolution_schema) would be nice of course ;-)
>But this can be done as a layer on top of yaml-cpp and that's perfectly
fine.
Well, the whole point for me (when I read the spec) that it must be in the
parser (how it is done in js-yaml).
What is a layer on top of yaml-cpp ?  What is the layer on top of PyYAML or
js-yaml ?
Where can read about layers ?

Cheers,
Andrey


On Fri, Mar 4, 2016 at 7:09 AM, Oren Ben-Kiki <[email protected]> wrote:

> On Fri, Mar 4, 2016 at 12:32 AM, Andrey Somov <[email protected]>
> wrote:
>
>> BTW, one of my proposals for YAML 2.0 is to drop these schemas. It should
>> be strictly application-specific. As you do. It should be driven by the
>> context which is outside of the YAML document. Users should not expect
>> auto-magic from the parser.
>>
>> Andrey
>>
>
> I am confused:
>
> In YAML 1.2 the schema *is* application specific. Which schema to apply is
> entirely the application's choice, *not* the parser's. That's the whole
> *point* of a schema. See section 3.1 of the spec - schema is applied as
> part of the "compose" phase, *not* the "parse" phase! So you don't need
> YAML2.0 here, 1.2 (for that matter, 1.1 and even 1.0) specifies exactly
> what you are asking for.
>
> In the terminology of section 3.3, yaml-cpp provides a "partial
> representation", which is a reasonable thing to do for a low-level YAML
> library. It is basically a parser and (the basis for) a composer.
> Schema-dependent tag resolution is the next logical processing step, which
> yaml-cpp doesn't do, and *isn't required to do*, by the spec.
>
> Just providing YAML::Token get_next_token() is a valid choice for a YAML
> library - that's what my YamlReference parser implementation does.
>
> Just providing YAML::Node load_partial_representation("foo.yaml") is a
> valid and useful design choice for a YAML library. That's what yaml-cpp
> does.
>
> Providing a YAML::Node load_complete_representation("foo.yaml",
> tag_resolution_schema) would be nice of course ;-) But this can be done as
> a layer on top of yaml-cpp and that's perfectly fine.
>
> Supporting the even higher level `template<T> T*  make_yaml<T>(const
> string& yaml)` functionality is very hard to do in C++ as there are no
> reflection services to speak of in C++. It is easier in Java which does
> have reflection, and is much easier in dynamic languages such as
> Perl/Python/Ruby, which is why YAML libraries in such languages tend to go
> "all the way".
>
> At any rate, yaml-cpp seems to be doing exactly what you are are asking
> for. It defers applying the schema to the application itself. And yet
> somehow you count that as a point *against* it?
>
> I'm confused :-)
>
> BTW - I use yaml-cpp myself in a side project I'm working on. It is rather
> nice. My main quibble with it is that passing YAML nodes by value has
> confusing semantics, but that is a C++-specific memory management issue.
>
> Oren.
>

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140

_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core