Re: [Yaml-core] Quoting rules

> On 2002.06.16, Oren Ben-Kiki <orenbk@...> wrote:
> > Ryan King [mailto:rking@...] wrote:
>
>
> Personally, I would go the complete opposite direction, and make the
> quoting rule this: "You only must quote that which is syntactically
> ambiguous."
>
> Pros:
> - It makes the output quieter. Ticks and double-ticks are noisy,
> and generally of no help to the humans, who can usually tell what
> is meant without them.
>
> - It makes the input easier for humans. A machine doesn't care if
> it has to put extra escaping around a string, but a human does.
> Therefore, we should minimize the amount of escaping needed by a
> hand-edited file, etc.), even if it means we trade a little
> syntactic simplicity for machine-generated files.
>
I really like the goal of making YAML a human-writable format. It's an
important niche for YAML to fill. If you just want persistence, most languages
have alternatives. If you want interoperability, XML's not a bad choice,
despite all its warts. But if you want human-writability, I don't really know
many good alternatives to YAML.
> Cons:
> - Causes migration issues as new implicit types are needed.
>
YAML's still young enough for this not to be a big issue.
> - Causes implementation issues (codifying "that which is
> syntactically ambiguous" into a set of productions would be a
> fairly challenging task)
>
Yep, but I think the cost/benefit ratio here could be well worth it.
> I recognize that the implicit types issue is a major caveat with my idea
> as-is. What if, then, we went with a different approach toward implicit
> types: To do away with them.
>
> Here is a theoretically possible rule set:
>
> - Every leaf is a string by default
>
> - Leaves preceded by "!foo" are given type "foo" (as they currently
> do)
>
> As a syntactic optimization, we could add this rule:
>
> - Leaves preceded by lone !'s are pattern-matched to determine types
>
> Examples:
> "5" # A string:
> 5 # Also just a string:
> !int 5 # This parses as an "int":
> ! 5 # Also parses as an "int", because the string "5" pattern-matches
>
I like this solution, although maybe !! would be better.