Files
hakorune/docs/private/ideas/new-features/2025-08-25-repl-mode.md

56 lines
1.4 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.

# REPL (Read-Eval-Print Loop) モード
Status: Idea
Created: 2025-08-25
Priority: Medium
Related: CLI機能拡張
## 概要
Nyashの対話的実行環境。Pythonのような即座にコードを試せる環境を提供。
## 想定される使用例
```bash
$ nyash --repl
Nyash REPL v1.0.0
>>> local x = 42
>>> print(x + 8)
50
>>> box Point { init { x, y } }
>>> local p = new Point()
>>> p.x = 10
>>> p.y = 20
>>> print(p)
Point { x: 10, y: 20 }
>>> exit()
```
## 実装案
### Phase 1: 基本REPL
- 単一行の評価と実行
- 変数の永続化
- 基本的なエラーハンドリング
### Phase 2: 高度な機能
- 複数行入力(継続行)のサポート
- ヒストリー機能(上下キーで履歴)
- タブ補完(変数名、メソッド名)
- `.help``.clear`などのメタコマンド
### Phase 3: デバッグ統合
- ブレークポイント設定
- 変数の詳細表示
- メモリ使用状況の確認
## 技術的考慮事項
- 現在のインタープリター構造との統合
- 状態管理(グローバルスコープの扱い)
- rustyline等のREPLライブラリの活用
## 実装タイミング
- [ ] 基本的な開発ツールが整った後
- [ ] ユーザーからの要望が多い場合
- [ ] 教育用途での需要が高まった場合
## 参考
- Python REPL
- Node.js REPL
- Rust playgroundWeb版も検討