Files
hakorune/docs/説明書/reference/box-design
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
..

📦 Nyash Box設計ドキュメント

🎯 概要

Nyashの核心哲学「Everything is Box」に関する完全な設計ドキュメント集。 言語設計の根幹から実装詳細まで、Box設計のすべてを網羅しています。

📚 ドキュメント構成

🌟 設計思想

everything-is-box.md

Nyashの核心哲学「Everything is Box」の完全解説。なぜすべてをBoxにするのか、その設計思想と利点を説明。

box-types-catalog.md

Nyashで利用可能な全Box型のカタログ。基本型StringBox, IntegerBoxから高度な型P2PBox, EguiBoxまで。

🔄 システム設計

delegation-system.md

完全明示デリゲーションシステムの設計。from構文、override必須、pack構文の詳細仕様。

memory-management.md

Arc一元管理、fini()システム、weak参照による循環参照回避の設計原則。

🌐 外部連携

ffi-abi-specification.md

Box FFI/ABI完全仕様。外部ライブラリを「箱に詰める」ための統一インターフェース。

🔧 実装ノート

implementation-notes/

開発者向けの実装詳細、既知の問題、進行中の設計変更などの技術情報。

🎨 設計原則

1. Everything is Box

すべての値がBoxオブジェクト。プリミティブ型は存在しない。

2. 明示性重視

暗黙的な動作を避け、すべてを明示的に記述。

3. Arc一元管理

Box内部でのロックを避け、インタープリターが一元管理。

4. メモリ安全性

fini()システムとweak参照による確実なメモリ管理。

🚀 クイックリファレンス

Box作成

// 基本型
local str = new StringBox("Hello")
local num = new IntegerBox(42)

// ユーザー定義Box
box User {
    init { name, email }
    
    birth(userName, userEmail) {
        me.name = userName
        me.email = userEmail
        print("🌟 User " + userName + " が誕生しました!")
    }
}

デリゲーション

box AdminUser from User {
    init { permissions }
    
    birth(adminName, adminEmail, perms) {
        from User.birth(adminName, adminEmail)
        me.permissions = perms
    }
    
    override toString() {
        return "Admin: " + from User.toString()
    }
}

ビルトインBox継承pack専用

// ビルトインBoxを継承する場合のみpackを使用
box EnhancedP2P from P2PBox {
    init { features }
    
    pack(nodeId, transport) {
        from P2PBox.pack(nodeId, transport)  // ビルトイン初期化
        me.features = new ArrayBox()
    }
    
    override send(intent, data, target) {
        me.features.push("send:" + intent)
        return from P2PBox.send(intent, data, target)
    }
}

外部ライブラリ統合FFI/ABI

// ExternBoxで外部APIを統一的に利用
local console = new ExternBox("console")
console.call("log", "Hello from Nyash!")

local canvas = new ExternBox("canvas")
canvas.call("fillRect", 10, 10, 100, 50)

📖 関連ドキュメント

🔄 更新履歴

  • 2025-08-14: Box設計ドキュメント初版作成
  • 2025-08-14: Phase 9.75Arc責務一元化対応開始

最終更新: 2025-08-14