Re: yaml-cpp and YAML 1.2
Oren Ben-Kiki <[email protected]> Fri, 4 Mar 2016 08:09:18 +0200
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CADJiDhvKKnRAYV0ddKjqBB5K+0qYutnaA4NKxOHqFUBdt12+=A@mail.gmail.com> |
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