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

@ -362,7 +362,38 @@ impl NyashInterpreter {
return Ok(field_value);
}
// 4. エラー:見つからない
// 4. statics名前空間内のstatic boxをチェック
eprintln!("🔍 DEBUG: Checking statics namespace for '{}'...", name);
if let Some(statics_namespace) = global_box.get_field("statics") {
eprintln!("🔍 DEBUG: statics namespace type: {}", statics_namespace.type_name());
// MapBoxとして試す
if let Some(map_box) = statics_namespace.as_any().downcast_ref::<crate::boxes::map_box::MapBox>() {
eprintln!("🔍 DEBUG: statics is a MapBox, looking for '{}'", name);
let key_box: Box<dyn NyashBox> = Box::new(StringBox::new(name));
let static_box_result = map_box.get(key_box);
// NullBoxでないかチェックMapBoxは見つからない場合NullBoxを返す
if static_box_result.type_name() != "NullBox" {
eprintln!("🔍 DEBUG: Found '{}' in statics namespace", name);
return Ok(Arc::from(static_box_result));
} else {
eprintln!("🔍 DEBUG: '{}' not found in statics MapBox", name);
}
} else if let Some(instance) = statics_namespace.as_any().downcast_ref::<crate::instance::InstanceBox>() {
eprintln!("🔍 DEBUG: statics is an InstanceBox, looking for '{}'", name);
if let Some(static_box) = instance.get_field(name) {
eprintln!("🔍 DEBUG: Found '{}' in statics namespace", name);
return Ok(static_box);
} else {
eprintln!("🔍 DEBUG: '{}' not found in statics InstanceBox", name);
}
} else {
eprintln!("🔍 DEBUG: statics namespace is neither MapBox nor InstanceBox");
}
}
// 5. エラー:見つからない
eprintln!("🔍 DEBUG: '{}' not found anywhere!", name);
Err(RuntimeError::UndefinedVariable {
name: name.to_string(),