This commit is contained in:
2026-06-16 01:27:54 +09:00
parent 5d6a03b74f
commit 4e82f47f90
31 changed files with 141 additions and 112 deletions
@@ -2,7 +2,7 @@
array expression は、順序付きの値の列を表す。
```n
```dcdl
[1, 2, 3]
["a", "b", "c"]
```
@@ -6,7 +6,7 @@ composition expression は、複数の値・制約・構造を合成する式で
`&` は制約を保った合成を行う。
```n
```dcdl
Port = Int & >= 1 & <= 65535;
Config = MyConfig & { port = 8000; };
```
@@ -15,7 +15,7 @@ Config = MyConfig & { port = 8000; };
`//` は右辺優先の構造的 patch を行う。
```n
```dcdl
Patched = Base // {
feature_hoge.enable = false;
};
@@ -2,7 +2,7 @@
`default` expression は、明示値が存在しない場合に materialize 時に採用される fallback を指定する。
```n
```dcdl
port = Int default 8080;
```
@@ -2,7 +2,7 @@
function call expression は、関数値を引数に適用する式である。
```n
```dcdl
mk_hw({
greet = "Hello";
target = "World";
@@ -2,7 +2,7 @@
function expression は、引数を受け取り式を返す値である。
```n
```dcdl
(part: {
greet = String;
target = String;
@@ -2,7 +2,7 @@
identifier expression は、現在の環境に束縛された名前を参照する式である。
```n
```dcdl
Port
MyConfig
mkConfig
@@ -2,7 +2,7 @@
import expression は、外部ファイルを読み込み、そのファイルの評価結果を返す。
```n
```dcdl
import ./config.n
import "./config.n"
```
+1 -1
View File
@@ -2,7 +2,7 @@
let expression は、ローカル束縛を作る。
```n
```dcdl
let
part = {
greet = "Hello";
@@ -4,7 +4,7 @@ literal expression は、ソース上に直接書かれる具体値である。
## 種類
```n
```dcdl
"hello"
123
3.14
@@ -2,7 +2,7 @@
match expression は、対象値を上から順に pattern と照合し、最初に一致した分岐を採用する。
```n
```dcdl
foo = match inputs.a.hoge {
>= 20: {
value = 200;
@@ -2,7 +2,7 @@
object expression は、名前付き field の集合を表す。
```n
```dcdl
{
host = "127.0.0.1";
port = 8000;
@@ -11,7 +11,7 @@ object expression は、名前付き field の集合を表す。
object は設定値にもスキーマにも使う。
```n
```dcdl
MyConfig = {
host = String;
port = Int default 8080;
@@ -22,7 +22,7 @@ MyConfig = {
ネストした field はドットパスでも定義できる。
```n
```dcdl
{
feature_hoge.enable = false;
}
@@ -30,7 +30,7 @@ MyConfig = {
これは以下と同じ構造を表す。
```n
```dcdl
{
feature_hoge = {
enable = false;
@@ -2,7 +2,7 @@
path reference expression は、object のフィールドを参照する式である。
```n
```dcdl
config.host
config.feature_hoge.enable
```
@@ -2,7 +2,7 @@
string interpolation は、文字列内に式を埋め込む候補機能である。
```n
```dcdl
"${part.greet}! ${part.target}"
```