summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/public/posts/2025-01-26/yaml-breaking-changes-between-v1-1-and-v1-2
diff options
context:
space:
mode:
Diffstat (limited to 'vhosts/blog/public/posts/2025-01-26/yaml-breaking-changes-between-v1-1-and-v1-2')
-rw-r--r--vhosts/blog/public/posts/2025-01-26/yaml-breaking-changes-between-v1-1-and-v1-2/index.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/vhosts/blog/public/posts/2025-01-26/yaml-breaking-changes-between-v1-1-and-v1-2/index.html b/vhosts/blog/public/posts/2025-01-26/yaml-breaking-changes-between-v1-1-and-v1-2/index.html
new file mode 100644
index 00000000..19161543
--- /dev/null
+++ b/vhosts/blog/public/posts/2025-01-26/yaml-breaking-changes-between-v1-1-and-v1-2/index.html
@@ -0,0 +1,141 @@
+<!DOCTYPE html>
+<html lang="ja-JP">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="author" content="nsfisis">
+ <meta name="copyright" content="&copy; 2025 nsfisis">
+ <meta name="description" content="データ記述言語 YAML におけるバージョン 1.1 と 1.2 の主な破壊的変更をまとめた。">
+ <meta name="keywords" content="YAML">
+ <meta property="og:type" content="article">
+ <meta property="og:title" content="【YAML】YAML 1.1 と YAML 1.2 の主な破壊的変更|REPL: Rest-Eat-Program Loop">
+ <meta property="og:description" content="データ記述言語 YAML におけるバージョン 1.1 と 1.2 の主な破壊的変更をまとめた。">
+ <meta property="og:site_name" content="REPL: Rest-Eat-Program Loop">
+ <meta property="og:locale" content="ja_JP">
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg">
+ <title>【YAML】YAML 1.1 と YAML 1.2 の主な破壊的変更|REPL: Rest-Eat-Program Loop</title>
+ <link rel="stylesheet" href="/style.css?h=79020a898c7052f79b32e90376a4497d">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
+ </head>
+ <body class="single">
+ <header class="header">
+ <div class="site-logo">
+ <a href="/">REPL: Rest-Eat-Program Loop</a>
+ </div>
+ <nav class="nav">
+ <ul>
+ <li>
+ <a href="/about/">About</a>
+ </li>
+ <li>
+ <a href="/posts/">Posts</a>
+ </li>
+ <li>
+ <a href="/slides/">Slides</a>
+ </li>
+ <li>
+ <a href="/tags/">Tags</a>
+ </li>
+ </ul>
+ </nav>
+ </header>
+ <main class="main">
+ <article class="post-single">
+ <header class="post-header">
+ <h1 class="post-title">【YAML】YAML 1.1 と YAML 1.2 の主な破壊的変更</h1>
+ <ul class="post-tags">
+ <li class="tag">
+ <a href="/tags/yaml/">YAML</a>
+ </li>
+ </ul>
+ </header>
+ <div class="post-content">
+ <section>
+ <h2 id="changelog">更新履歴</h2>
+ <ol>
+ <li class="revision">
+ <time datetime="2021-06-30">2021-06-30</time>: デジタルサーカス株式会社の社内記事として公開
+ </li>
+ <li class="revision">
+ <time datetime="2025-01-26">2025-01-26</time>: ブログ記事として一般公開
+ </li>
+ </ol>
+ </section>
+ <div class="admonition">
+ <div class="admonition-label">
+ NOTE
+ </div>
+ <div class="admonition-content">
+ この記事は、2021-06-30 に<a href="https://www.dgcircus.com/">デジタルサーカス株式会社</a> の社内 Qiita Team に公開された記事をベースに、加筆修正して一般公開したものです。
+ </div>
+ </div>
+
+ <section id="section--intro">
+ <h2><a href="#section--intro">はじめに</a></h2>
+ <p>
+ データ記述言語の一つ YAML には 1.0、1.1、1.2 のバージョンがある。 これらのうち、1.1 と 1.2 の間には無視できない非互換の変更が多く、1.2 に対応していないライブラリもある (Ruby 同梱の <code>yaml</code> など)。 この記事では、YAML 1.1 と YAML 1.2 の主な破壊的変更を紹介する (影響範囲が広いものを抜粋しており、すべての非互換を網羅してはいない)。
+ </p>
+
+ <p>
+ 参照した仕様書はこちら: <a href="https://yaml.org/spec/1.2.2/ext/changes/">https://yaml.org/spec/1.2.2/ext/changes/</a>
+ </p>
+ </section>
+
+ <section id="section--breaking-changes">
+ <h2><a href="#section--breaking-changes">主な破壊的変更</a></h2>
+ <section id="section--breaking-changes--boolean-literals">
+ <h3><a href="#section--breaking-changes--boolean-literals">Boolean としてパースされるトークンが <code>true</code> / <code>false</code> とその亜種のみに</a></h3>
+ <p>
+ この変更の影響が最も大きいと思われる。 YAML 1.1 では、boolean 値のリテラルとして <code>true</code>、<code>false</code> のほか <code>yes</code>、<code>no</code>、<code>y</code>、<code>n</code>、<code>on</code>、<code>off</code>、それらの大文字バージョンなどが認められていた。 YAML 1.2 では、<code>true</code> と <code>false</code>、それらの大文字バージョン (<code>True</code>、<code>TRUE</code>、<code>False</code>、<code>FALSE</code>) のみが boolean としてパースされるようになった。
+ </p>
+ </section>
+
+ <section id="section--breaking-changes--octal-literals">
+ <h3><a href="#section--breaking-changes--octal-literals">八進数リテラルには <code>0o</code> が必須に</a></h3>
+ <p>
+ C 言語などでは、<code>0</code> から始まる数字の列を八進数としてパースする。 YAML 1.1 もこれに準じていたが、1.2 からは <code>0o</code> のプレフィクスが必須となった (&quot;o&quot; は &quot;octal&quot; の &quot;o&quot;)。 プログラミング言語では、Python や Haskell、Swift、Rust などがこの記法を採用している。
+ </p>
+ </section>
+
+ <section id="section--breaking-changes--merging">
+ <h3><a href="#section--breaking-changes--merging"><code>&lt;&lt;</code> によるマージが不可能に</a></h3>
+ <p>
+ YAML 1.1 では、<code>&lt;&lt;</code> という文字列をキーに指定することで、マップをマージすることができた。
+ </p>
+
+ <pre class="highlight" language="yaml"><code class="highlight"><span class="hljs-attr">x:</span> <span class="hljs-meta">&amp;base</span>
+ <span class="hljs-attr">a:</span> <span class="hljs-number">123</span>
+<span class="hljs-comment"># =&gt; { &quot;x&quot;: { &quot;a&quot;: 123 } }</span>
+
+<span class="hljs-attr">y:</span>
+ <span class="hljs-string">&lt;&lt;:</span> <span class="hljs-meta">*base</span>
+ <span class="hljs-attr">b:</span> <span class="hljs-number">456</span>
+<span class="hljs-comment"># =&gt; { &quot;y&quot;: { &quot;a&quot;: 123, &quot;b&quot;: 456 } }</span></code></pre>
+
+ <p>
+ 1.2 からはこれができなくなる。
+ </p>
+ </section>
+
+ <section id="section--breaking-changes--number-separator">
+ <h3><a href="#section--breaking-changes--number-separator">数字を <code>_</code> で区切るのが禁止に</a></h3>
+ <p>
+ <code>1234567</code> を <code>1_234_567</code> と書けなくなった。
+ </p>
+ </section>
+ </section>
+
+ <section id="section--outro">
+ <h2><a href="#section--outro">おわりに</a></h2>
+ <p>
+ 全体的に、<i>There&apos;s more than one way to do it.</i> から <i>There should be one - and preferably only one - obvious way to do it.</i> へ移行しているように思われる。 データ記述言語としては望ましい方向性ではないかと感じる。
+ </p>
+ </section>
+ </div>
+ </article>
+ </main>
+ <footer class="footer">
+ &copy; 2021 nsfisis
+ </footer>
+ </body>
+</html>