68 lines
2.6 KiB
Markdown
68 lines
2.6 KiB
Markdown
# Features
|
|
|
|
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
|
|
|
|
`decodal` defaults to `std` only.
|
|
|
|
```toml
|
|
[features]
|
|
default = ["std"]
|
|
std = []
|
|
regex = ["std", "dep:regex"]
|
|
```
|
|
|
|
Building `decodal` with `--no-default-features` keeps the core in `no_std + alloc` mode and avoids optional dependencies.
|
|
|
|
## Regex
|
|
|
|
Regex constraints are implemented behind the `regex` feature.
|
|
When the feature is disabled, regex constraints parse and compose, but validating a concrete value against them returns an unsupported feature diagnostic.
|
|
|
|
```sh
|
|
cargo run -q -p decodal-cli --features regex -- examples/regex/main.dcdl
|
|
```
|
|
|
|
Regex constraints are accumulated during `&` composition.
|
|
The implementation does not try to prove whether the intersection of two regex constraints is empty.
|
|
Concrete strings must match every regex constraint attached to the abstract value.
|
|
|
|
## CLI features
|
|
|
|
`decodal-cli` exposes a matching `regex` feature that enables `decodal/regex`.
|
|
The feature is not enabled by default so the default CLI binary remains small.
|