Re: The same tag for different kinds
Oren Ben-Kiki <[email protected]> Fri, 11 Mar 2016 02:30:36 +0200
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CADJiDhvpXJn8F4vnvX5G5tc0akYsQCiwqGjF7oGi2YPL2__pwQ@mail.gmail.com> |
Presumably complain. What would it do with !!int {} ?
On Thu, Mar 10, 2016 at 11:22 PM, Andrey Somov <[email protected]>
wrote:
>
>
> On Thu, Mar 10, 2016 at 8:21 PM, Oren Ben-Kiki <[email protected]> wrote:
>
>> On Thu, Mar 10, 2016 at 7:10 PM, Andrey Somov <[email protected]>
>> wrote:
>>
>>> The tag itself does not give any indication which node kind it needs.
>>>
>>
>> What do you mean? The spec requires certain things from each tag, this is
>> one.
>>
>
> I mean that !foo is not related to any kind. It can be used with any node.
>
>
>>
>>> Or "each tag must specify the expected node kind" must be read as "each
>>> tag can only be applied to the node kind it is used with" ?
>>>
>>
>> Yes.
>>
>>
>>> My question is: should the parser be prepared to get a custom tag for
>>> different kinds ?
>>> Should the parser allow to configure to call different custom
>>> implementations for different kinds for the same tag ?
>>>
>>
>> I'm assuming you are misusing the word parser here. A YAML processor that
>> constructs native application data needs to (1) associate tags with all
>> nodes and (2) map the tags to native data types and (3) then construct them.
>>
>> There's no requirement that different tags map to different native data
>> types (e.g., in JavaScript, !!int and !!float map to the same native number
>> type).
>>
>> YAML requires that tags-that-are-associated-with-scalar-nodes be
>> different than tags-that-are-associated-with-map-nodes which must be
>> different than tags-that-are-associated-with-sequence-nodes.
>>
>
> I think this is the answer to my question. It means that users have to
> provide a separate implementation for every kind for the same tag.
>
> (1) associate tags with all nodes => this is done by the processor
> (2) map the tags to native data types => this has to be implemented by
> users
> (3) then construct them => this has to be implemented by users
>
>
>> BTW, since tags are URIs, one can do things like !!foo#scalar vs.
>> !!foo#map vs. !!foo#seq to communicate they are related. Or use `/` or `::`
>> or `-` or whatever.
>>
>> Oren.
>>
>
> What should the processor do in this case ?
>
> %YAML 1.1
> ---
> scalar: !foo#map bar
> map: !foo#scalar {a: 1}
>
>
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core