From 0d443dd6fa5c5083a80cb5b811c37501a976a01a Mon Sep 17 00:00:00 2001 From: Selfhosting Dev Date: Tue, 23 Sep 2025 02:03:48 +0900 Subject: [PATCH] docs: Fix peek/match documentation inconsistencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update CLAUDE.md: peek式 → match式, peek構文 → match構文 - Update LANGUAGE_REFERENCE_2025.md: Peek式 → Match式 - Fix default pattern: else → _ (underscore) - Resolve confusion causing JSON development Claude to use incorrect syntax This fixes the root cause where new AI developers were referencing outdated 'peek' syntax examples and getting parse errors, forcing them to rewrite with 'if' statements instead of using the correct 'match' syntax. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 14 +++++++------- docs/reference/language/LANGUAGE_REFERENCE_2025.md | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 145d0944..7b23d0f6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -391,28 +391,28 @@ a / b // 除算(ゼロ除算エラー対応済み) a + b, a - b, a * b // 加算・減算・乗算 ``` -### 🎯 peek式(パターンマッチング) +### 🎯 match式(パターンマッチング) ```nyash // 値を返す式として使用 -local dv = peek d { +local dv = match d { "0" => 0, "1" => 1, "2" => 2, - else => 0 + _ => 0 } // ブロックで複雑な処理も可能 -local result = peek status { +local result = match status { "success" => { log("OK"); 200 } "error" => { log("NG"); 500 } - else => 404 + _ => 404 } // 文として使用(値を捨てる) -peek action { +match action { "save" => save_data() "load" => load_data() - else => print("Unknown") + _ => print("Unknown") } ``` diff --git a/docs/reference/language/LANGUAGE_REFERENCE_2025.md b/docs/reference/language/LANGUAGE_REFERENCE_2025.md index bb9706bc..9f563f5f 100644 --- a/docs/reference/language/LANGUAGE_REFERENCE_2025.md +++ b/docs/reference/language/LANGUAGE_REFERENCE_2025.md @@ -196,14 +196,14 @@ loop() { } # 無条件ループは `loop(true){}` を意図明確 > 設計メモ: Nyashは「単一入口・先頭条件」の制御フロー規律を重視するため、do‑whileは採用しません。必ず実行の表現は `loop(1)` ラッパーや `repeat/until` 糖衣からゼロコストで正規化します。 ``` -#### **Peek式(Phase 12.7で追加)** +#### **Match式(Phase 12.7で追加)** ```nyash # パターンマッチング風の分岐 local result = match value { "A" => 100, "B" => 200, "C" => 300, - else => 0 # else必須 + _ => 0 # _はデフォルトパターン } # 文の形式も可 @@ -215,7 +215,7 @@ match status { "success" => { print("All good") }, - else => { + _ => { print("Unknown status") } }