Skip to content

Eliminate Directives

Ingy döt Net edited this page Nov 28, 2011 · 3 revisions

Currently, YAML has only 2 directives:

%YAML 1.2
%TAG ! tag:clarkevans.com,2002:

While this information is important, and there is lots of other information that is important for understanding the true nature of a YAML document, we should not put this information inside the document.

Rationale

YAML documents have never been able to truly stand on their own. Any processor can load any YAML document in any way it wants to. As programmers using YAML, the meaning of YAML is inherant in the particular processor we use and the way we choose to configure that processor.

We should embrace the concept that the true meaning of a YAML document is always a combination of the content of the document and the schema (ie processor) it is loaded with.

If that is the case, then YAML version and tag mappings are just two of the myriad configuration options, and they need to not be a part of the language.

In the wild, directives are rarely used. As we embark on the process of defining new schema and formatting languages for YAML, we should make the linking of them to YAML documents be an external exercise.

This will make the YAML language a lot cleaner conceptually, and will give us more rope to try various external experimentation.

Implications

We don't need two different document separators:

---
foo: bar
...
---
- foo
- bar
...

In the wild, --- is very common and ... is not. We can just use the former, but we should change the semantics to mean "just a separator".

Currently, this stream:

---
---
---

means:

---
null
---
null
---
null

In YAML 2.0, it should mean the same as an empty stream. So then you can use --- to terminate a document (in a streaming context) and start the next doc with it.

Clone this wiki locally