Files
hakorune/local_tests/plugin_design_consultation.txt
Moe Charm 72b63546b0 feat(phase-9.75g-0): Add simple nyash.toml parser for plugin configuration
-  Simple TOML parser for [plugins] section
-  Maps Box names to plugin names (e.g., FileBox => filebox)
-  Handles comments and empty lines
-  Complete test coverage
- 🎯 Minimal implementation for transparent Box replacement!

Part of Day 4 FileBox plugin implementation (60% → 70%)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 22:05:47 +09:00

94 lines
2.2 KiB
Plaintext
Raw Permalink 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.

Nyashプログラミング言語のプラグインシステムについて相談です。
プラグインのインターフェース定義をYAML/JSONで外部化する設計を検討しています。
【要件】
- 簡単で分かりやすい
- 階層が深くならない
- 必要な機能は入れる
- FileBox.open() のような静的メソッドも定義できる
- Everything is Box哲学を維持
【案1: YAML設計図方式】
```yaml
plugin:
name: FileBox
type_id: 6
version: "1.0.0"
static_methods:
open:
args: [path: string, mode?: string]
returns: FileBox
default_args: {mode: "r"}
exists:
args: [path: string]
returns: bool
methods:
read:
args: [size?: number]
returns: string
write:
args: [content: string]
returns: number
close:
args: []
returns: void
```
【案2: より簡潔なJSON】
```json
{
"FileBox": {
"static": {
"open(path, mode='r')": "FileBox",
"exists(path)": "bool"
},
"methods": {
"read(size?)": "string",
"write(content)": "number",
"close()": "void"
}
}
}
```
【案3: 最小限のTOML】
```toml
[FileBox]
type_id = 6
[FileBox.static]
open = "path:string, mode:string? -> FileBox"
exists = "path:string -> bool"
[FileBox.methods]
read = "size:number? -> string"
write = "content:string -> number"
close = "-> void"
```
【案4: プラグイン実装に埋め込む】
Rustコードに属性マクロで定義を埋め込む
```rust
#[plugin_box(type_id = 6)]
impl FileBoxPlugin {
#[static_method]
fn open(path: String, mode: Option<String>) -> BidHandle { ... }
#[method]
fn read(&self, handle: BidHandle, size: Option<usize>) -> Vec<u8> { ... }
}
```
【質問】
1. どの方式が最も実用的でしょうか?
2. 静的メソッドとインスタンスメソッドの区別をどう表現するのが良いでしょうか?
3. メンテナンス性と実装の簡単さのバランスはどう取るべきでしょうか?
4. 他により良い設計パターンはありますか?
プログラミング言語設計の観点から、シンプルさと拡張性のバランスを重視してアドバイスをお願いします。