Files
hakorune/docs/archive/decisions/design-decisions/constructor-name-decision.md
Moe Charm cc2a820af7 feat(plugin): Fix plugin BoxRef return and Box argument support
- Fixed deadlock in FileBox plugin copyFrom implementation (single lock)
- Added TLV Handle (tag=8) parsing in calls.rs for returned BoxRefs
- Improved plugin loader with config path consistency and detailed logging
- Fixed loader routing for proper Handle type_id/fini_method_id resolution
- Added detailed logging for TLV encoding/decoding in plugin_loader_v2

Test docs/examples/plugin_boxref_return.nyash now works correctly:
- cloneSelf() returns FileBox Handle properly
- copyFrom(Box) accepts plugin Box arguments
- Both FileBox instances close and fini correctly

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 00:41:26 +09:00

115 lines
3.5 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.

# 🌟 Nyash コンストラクタ名決定: birth() 採用
**決定日**: 2025-08-15
**決定者**: Nyashプロジェクトチーム
**ステータス**: 正式決定
## 🎯 **最終決定**
**`birth()` を唯一のコンストラクタ名として採用**
## 📋 **検討経過**
### 候補と評価
1. **constructor()** - 業界標準だが長い、Box哲学との親和性低い
2. **pack()** - Box哲学完璧だが独自性強すぎ、混乱の元
3. **init()** - initフィールドとの混乱、廃止済み
4. **make()** - Go言語実績あり、短い、実用的
5. **birth()** - 🌟 **採用決定** 🌟
### birth() 選定理由
**1. 哲学的完璧性**
- 「Everything is Box」哲学との完璧な親和性
- 「Boxに魂が宿る」生命感のある言語思想を体現
- 「生命を誕生させる」直感的イメージ
**2. 強力なブランディング効果**
- 圧倒的独自性で一度見たら忘れない
- Nyashらしさを言語の核心で表現
- 学習者がコンストラクタを使うたびに世界観を体感
**3. 実用性**
- 短い5文字で覚えやすい
- 学習コストは低い(初見で一瞬考えるだけ)
- 明確で曖昧性がない
## 💡 **Geminiの専門的評価**
> 「`birth()` を採用することは、単なる名前選び以上の意味を持つ。それは、**Nyashの哲学を言語の根幹に据えるという宣言**である。学習者はコンストラクタを使うたびに、無意識にその世界観に触れることになる。これは非常に強力なブランディングです。」
**Gemini最終推奨**: `birth()` 採用
## 🌟 **構文例**
```nyash
// 基本的な使用法
box Life {
init { name, energy }
birth(lifeName) { // 生命を誕生させる
me.name = lifeName
me.energy = 100
print("🌟 " + lifeName + " が誕生しました!")
}
}
// デリゲーション
box Human from Life {
init { intelligence }
birth(humanName) {
from Life.birth(humanName) // 親から生命を受け継ぐ
me.intelligence = 50
}
}
// 使用例
local alice = new Human("Alice") // birth()が自動呼び出し
```
## 🔧 **実装要件**
### 1. トークナイザー修正
```rust
BIRTH, // birth (コンストラクタ)
"birth" => TokenType::BIRTH,
```
### 2. パーサー修正
- `birth()` 構文パース対応
- `init/pack/constructor` と同様の処理システム統合
### 3. インタープリター修正
- `birth/引数数` キーでの検索対応
- デリゲーション時の `from Parent.birth()` サポート
### 4. 優先順位システム
```rust
// 検索順序
1. "birth/引数数" // 最優先
2. "init/引数数" // 互換性
3. "pack/引数数" // 互換性
4. "Box名/引数数" // 互換性
```
## 🎉 **期待される効果**
- **哲学的一貫性**: Everything is Box思想の完璧な体現
- **ブランド確立**: Nyash独自の世界観を言語レベルで表現
- **学習体験向上**: コンストラクタ使用のたびに世界観を体感
- **混乱解消**: initフィールドとの完全な区別
- **統一性**: 全てのBoxで同一のbirth()構文
## 📝 **移行計画**
1. **Phase 1**: birth()実装(トークナイザー・パーサー・インタープリター)
2. **Phase 2**: テスト作成・動作確認
3. **Phase 3**: 既存コード段階的移行(互換性維持)
4. **Phase 4**: ドキュメント更新CLAUDE.md等
---
**🌟 Nyashは `birth()` でBoxに生命を与える言語として、新たな進化を遂げる 🌟**