feat(constructor): implement birth() syntax and pack transparency system

## 🌟 birth() Constructor Implementation
- Add BIRTH token to tokenizer (src/tokenizer.rs:37,403)
- Implement birth() parser support (src/parser/mod.rs)
- Add birth() interpreter support with priority system
- Priority: birth > pack > init > Box名

## 🚨 Fix Documentation Inconsistencies
- Fix delegation-system.md: pack → birth unified
- Fix box-design/README.md: add pack-specific section
- Fix LANGUAGE_GUIDE.md: birth unified, pack builtin-only
- Fix CLAUDE.md: birth philosophy, pack system separation

## 📋 pack Transparency System Design
- Create phase_8_8_pack_transparency_system.md specification
- Establish correct pack definition: builtin Box inheritance only
- Design user-transparent system: from BuiltinBox() → internal pack
- Comprehensive test cases and implementation requirements

## 🧪 Testing
- Add test_birth_simple.nyash: birth() functionality verification
- Document constructor name decision process
- Prepare for Copilot implementation with clear specifications

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-15 19:34:26 +09:00
parent 6bb288b694
commit 6b62209da9
13 changed files with 727 additions and 44 deletions

View File

@ -713,12 +713,14 @@ impl NyashInterpreter {
let instance_arc = Arc::from(instance_box);
// コンストラクタを呼び出す
// "pack/引数数"、"init/引数数"、"Box名/引数数" の順で試す
// "birth/引数数"、"pack/引数数"、"init/引数数"、"Box名/引数数" の順で試す
let birth_key = format!("birth/{}", arguments.len());
let pack_key = format!("pack/{}", arguments.len());
let init_key = format!("init/{}", arguments.len());
let box_name_key = format!("{}/{}", actual_class_name, arguments.len());
if let Some(constructor) = final_box_decl.constructors.get(&pack_key)
if let Some(constructor) = final_box_decl.constructors.get(&birth_key)
.or_else(|| final_box_decl.constructors.get(&pack_key))
.or_else(|| final_box_decl.constructors.get(&init_key))
.or_else(|| final_box_decl.constructors.get(&box_name_key)) {
// コンストラクタを実行