docs(repl): Phase 288 documentation cleanup

Updated documentation to reflect actual implementation status:
- docs/reference/language/repl.md: Corrected examples (variable persistence TODO)
- docs/development/current/main/10-Now.md: Phase 288 completion noted
- docs/development/current/main/30-Backlog.md: Updated with Phase 288.1 tasks
- docs/development/current/main/phases/phase-288/: Added phase documentation

Accurate REPL behavior examples:
- x = 1 works (implicit local)
- print(x) errors (persistence in Phase 288.1)
- Expression auto-display deferred

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-25 14:01:32 +09:00
parent 38968efa3c
commit 2b86b658d8
5 changed files with 121 additions and 11 deletions

View File

@ -2,10 +2,10 @@
## Current Focus (next)
- Phase 287stabilization: ビルド/テスト軽量化quick が重すぎる)
- 目的: `tools/smokes/v2/run.sh --profile quick` を「開発中に回せる速さ」に戻す(意味論不変、分類/配置で解決
- 入口: `docs/development/current/main/phases/phase-287/README.md`
- 手順: `docs/development/current/main/phases/phase-287/P1-INSTRUCTIONS.md`
- Phase 288.1dev-tools: REPL session persistence + auto-display
- 目的: `hakorune --repl` で変数が行を跨いで生きる暗黙local式の自動表示`_` を含む
- 入口: `docs/development/current/main/phases/phase-288/README.md`
- 手順: `docs/development/current/main/phases/phase-288/P1-INSTRUCTIONS.md`
- Phase 284design-first: Return as ExitKind SSOTpatternに散らさない
- 目的: `return``ExitKind` + `compose::*` / `emit_frag()` に収束させ、pattern側の個別実装を増やさない

View File

@ -8,6 +8,11 @@ Related:
## 直近JoinIR/selfhost
- **Phase 288✅ P0P3 complete: REPL mode**
- 入口: `docs/development/current/main/phases/phase-288/README.md`
- SSOT: `docs/reference/language/repl.md`
- 次: Phase 288.1session persistence / auto-display `docs/development/current/main/phases/phase-288/P1-INSTRUCTIONS.md`
- **Phase 287active, stabilization: ビルド/テスト軽量化quick が重すぎる)**
- 目的: `tools/smokes/v2/run.sh --profile quick` を 45秒以内目安へ戻し、開発サイクルを軽くする
- 入口: `docs/development/current/main/phases/phase-287/README.md`

View File

@ -0,0 +1,62 @@
# Phase 288.1 P1: REPL Session Persistence + Auto-Display (instruction sheet)
## Objective
- Make REPL variables persist across input lines (`x = 1` then `print(x)` works).
- Add minimal expression auto-display and `_` last-value binding (REPL-only).
- Keep file mode semantics unchanged; quick smokes must remain green.
SSOT:
- `docs/reference/language/repl.md`
## Constraints (non-negotiable)
- No new env vars.
- No file-mode behavior changes.
- Keep REPL-specific state and logic isolated (Box-first).
## Design (recommended)
Do **not** persist `ValueId` across evaluations. Persist runtime values (VMValue/handle) in `ReplSessionBox`, and bridge them via a REPL-only rewrite step.
### Bridge approach: REPL-only AST rewrite
In REPL mode, rewrite variable reads/writes that are not declared in the current input line into calls against a REPL session object:
- Read `x``__repl.get("x")`
- Assignment `x = expr``__repl.set("x", expr)`
- `_` is treated as a normal name in the session (written by auto-display).
This keeps the parser unchanged and avoids contaminating the normal MIR builder scope model.
### Session API (REPL-only)
Provide a minimal host object `__repl` with:
- `get(name: String) -> Any` (Fail-Fast if missing)
- `set(name: String, value: Any) -> void`
- `reset() -> void`
Implementation options:
- Rust VM only (initially): inject `__repl` as a built-in box/object available only in `--repl`.
- LLVM parity is not required for Phase 288.1; REPL is a dev tool.
## Step-by-step
1) Add a REPL-only `__repl` host object and VM handlers for `get/set/reset`.
2) Implement AST rewrite in the REPL runner before compilation:
- Collect “declared names” in the current line (`local name`, function params, etc.).
- Rewrite remaining identifier reads/writes to `__repl.get/set`.
3) Implement auto-display:
- If the input is a pure expression, `print(result)` (or equivalent) in REPL only.
- Store result into session name `_` (skip if `void`).
4) Add conformance checks (manual is OK if no test harness exists yet):
- `x = 1` (silent)
- `print(x)` prints `1`
- `y` (read) is NameError
- `1 + 1` prints `2` and `_` becomes `2`
- `.reset` clears variables (`print(x)` errors)
5) Run regression gate:
- `./tools/smokes/v2/run.sh --profile quick` must stay `0 FAILED`.

View File

@ -0,0 +1,33 @@
# Phase 288: REPL mode (design-first, file-mode unaffected)
Status: ✅ P0P3 complete (2025-12-25) / ⏳ 288.1 next
Goal: Add an interactive REPL for Nyash while keeping file mode semantics unchanged and keeping the language SSOT stable.
SSOT:
- REPL spec: `docs/reference/language/repl.md`
## Scope
- CLI entry: `hakorune --repl` / `-i`
- REPL commands: `.help`, `.exit/.quit`, `.reset`
- Fail-Fast: undefined reads are errors
- File mode: no behavior changes (quick smokes remain green)
## Completed (P0P3)
- P0: SSOT doc established/updated (`docs/reference/language/repl.md`)
- P1: CLI entry point (`--repl` / `-i`)
- P2: REPL session state isolated (Box-first; runtime-value based)
- P3: Minimal UX and docs polish
## Next (Phase 288.1)
The MVP intentionally deferred these:
- Session variable **persistence across lines** (bridge session → compilation/runtime)
- Expression auto-display + `_` last-value binding
- Multi-line input handling (continuations)
Entry: `docs/development/current/main/phases/phase-288/P1-INSTRUCTIONS.md`