diff --git a/doc/manual/souce/design/features.md b/doc/manual/souce/design/features.md index 014a91e..ca38a4e 100644 --- a/doc/manual/souce/design/features.md +++ b/doc/manual/souce/design/features.md @@ -1,6 +1,39 @@ # Features -Decodal keeps the embedded core small by making heavy functionality opt-in. +Decodal は embedded use と小さい runtime を優先する。 +言語機能を追加するときは、値の合成・検証・materialization に直接必要なものを core に残し、重い依存や高度な推論は optional feature または外部 tooling に分ける。 + +## Core feature boundary + +Core に入れる機能は、基本的に deterministic な value transformation に限る。 + +- arithmetic / logical / comparison operators +- array concat +- object / constraint composition +- default materialization +- pure function evaluation +- host supplied import evaluation + +Core に入れないものは以下である。 + +- filesystem / network / environment access +- time / random +- mutation +- reflection or existence probing +- arbitrary host function calls +- symbolic constraint solving beyond simple normalization + +未解決 identifier や missing field は `unknown` として流れず、diagnostic になる。 +この方針により、存在チェックや optional chaining のような dynamic object inspection は core language の対象外とする。 + +## Constraint reasoning + +Constraint normalization は軽量な範囲に留める。 +primitive type conflict や明らかな numeric bound conflict は合成時に検出してよい。 +一方で、symbolic arithmetic、boolean algebra、regex intersection、array length dependent typing のような重い推論は行わない。 + +評価済みの concrete value に対する検証は runtime / materialization で行う。 +静的に完全な型検査フェーズを増やすのではなく、parse、evaluate、compose、materialize の各段階で自然に分かる error を diagnostic として返す。 ## Core defaults diff --git a/doc/manual/souce/design/runtime-model.md b/doc/manual/souce/design/runtime-model.md index b8aa7f3..b097b7d 100644 --- a/doc/manual/souce/design/runtime-model.md +++ b/doc/manual/souce/design/runtime-model.md @@ -14,6 +14,10 @@ RuntimeValue = `Concrete` は明示的な値である。 `Abstract` は、まだ具体値に確定していない制約付きの値である。 +Decodal は `unknown`、`any`、`null` のような「存在するが意味が未確定な値」を runtime value として持たない。 +識別子や field が解決できない場合は、その場で diagnostic になる。 +未解決値を後続の演算へ流して推論することはしない。 + ## ConcreteValue ```text @@ -88,6 +92,21 @@ port = 8000; Concrete(Int(8000)) ``` +## Runtime scope + +Decodal runtime は application runtime ではなく、pure value evaluator である。 +同じ source、同じ import sources、同じ host globals が与えられた場合、評価結果は決定的である。 + +runtime が扱う責務は以下に限る。 + +- expression を評価する。 +- thunk を必要に応じて force する。 +- concrete / abstract value を合成する。 +- materialize 時に constraint を検証する。 + +runtime は filesystem、network、environment variable、time、random、mutation を扱わない。 +core における import は host supplied source を受け取る境界であり、filesystem access ではない。 + ## Constraint constraint は concrete value とは別の型として扱う。