Files
hakorune/docs/guides/source-extensions.md

37 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Source Extensions Policy — .nyash vs .hako (Interim)
Intent
- Keep development stable while Hakorune VM (v1 Dispatcher/IR/φ) is brought up.
- Avoid crosscontamination between frontends; converge at MIR.
Execution Mapping (current)
- .nyash → Nyash VM (Rust): NyashParser → MIR → VM. Full runtime/plugins path.
- .hako → Hakorune VM (v1): JSON v1 Dispatcher/IR/φbringup coverage; guarded extern.
- verify (MIR v1) → Hakorune primary, Core fallback for diagnosis.
Resolver/Include/Normalize
- Using: unify to textmerge (merge_prelude_text). AST prelude merge is retired.
- Include: languagelevel unsupported; quick profile treats include as ERROR. Preinclude is testharness onlyverify の include fallback は撤去済み)。
- Normalize (inline/dev): CRLF→LF, redundant `; }` trimmed, tolerant `local` at line head in Hakorune inline drivers.
FailFast Guards
- Hako in Nyash VM: rejected by default (FailFast). Toggle: `HAKO_FAIL_FAST_ON_HAKO_IN_NYASH_VM=0` for dev only.
- Extern (Hako provider): `HAKO_V1_EXTERN_PROVIDER=1`; optional CABI tag/bridge with `HAKO_V1_EXTERN_PROVIDER_C_ABI=1` (default OFF).
Why two extensions now?
- Same language intent, but different stability constraints at the frontend boundary:
- .hako through NyashParser caused parse/timeout/alias issues historically.
- We intentionally stopped that path and direct .hako to Hakorune VM while it matures.
Migration Plan (phased)
1) P2: IR iteration complete; φ table robust; dispatcher loop scanfree; extern canaries PASS without harness shim.
2) P3: verify default → Hakorune (Core fallback); document toggles and remove adhoc heuristics.
3) Prep: introduce stable Nyash→MIR v1 emit route to feed Hakorune VM when (and if) we want .nyash on hv1.
4) Deprecation: warn on `.nyash` (optin), then FailFast once hv1 parity is sufficient; remove legacy code in a later phase.
Best Practices (now)
- Prefer alias/modules over path using; avoid include in source.
- Keep quotes ASCII (`"`); avoid trailing semicolons before `}`.
- For verify, pass JSON via env (`NYASH_VERIFY_JSON`) and parse last numeric line as rc.
- Inline-cドライバは alias のみで構成include 不要)。