Re: Can an alias be used to define a new anchor?
Bartek Grychtol <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CAPiZYx08LD2sCQFsrPkwHjOJ6bckReK3uV+EmquxSDEUQgmD+w@mail.gmail.com> |
On Tue, Sep 9, 2014 at 2:32 PM, Peter Murphy <[email protected]> wrote: > On Tue, Sep 9, 2014 at 9:27 PM, Bartek Grychtol <[email protected]> > wrote: > > Hello List, > > > > I'm new to YAML, which we're using in a project via yaml-cpp. I stumpled > > into an issue which I don't know if it's a bug in yaml-cpp or a feature > of > > the spec. I consulted the spec but left no wiser. > > > > I wanted to write a node like this: > > --- > > Images: > > one: > > size_x: &ONE_SIZE 100 > > two: > > size_x: &TWO_SIZE *ONE_SIZE > > > > That is, I was hoping to use an alias to define a new anchor. The > motivation > > is that *TWO_SIZE is used lower down independently of *ONE_SIZE, yet they > > are sometimes, but not always, one and the same thing. > > > > yaml-cpp refuses to parse this. Is it legal YAML? > > > > Thanks in advance! > > > > Bartek > > > > Bartek, > > I'm afraid it is not legal YAML. Once you assign an anchor name to a > node, you have to reuse that anchor name for all aliases. > > The production for aliases is under section 7.1. > > http://www.yaml.org/spec/1.2/spec.html#id2786196 > > [104] c-ns-alias-node ::= “*” ns-anchor-name > > [102] ns-anchor-char ::= ns-char - c-flow-indicator > [103] ns-anchor-name ::= ns-anchor-char+ > > In the current spec (1.2), there is no way of assigning multiple > anchor/alias names to the same node. > > However, there may be future versions of the spec which don't have > this limitation. > > Best regards, > Peter > > Hi Peter, Thanks a lot for the quick answer. I guess I'll have to work around it then. I wonder what's the reason behind this design decision, though..? Best, Bartek ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce. Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ Yaml-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/yaml-core