This repository was archived by the owner on Aug 18, 2025. It is now read-only.
  
  
  
  
v0.4.0
CodeNothing Programming Language Interpreter v0.4.0 Changelog
🎉 Major Feature Update: Switch Statement Support
📋 Version Information
- Version: v0.4.0
- Release Date: 2025-07-24
- Update Type: Major Feature Update
🚀 New Features
✨ Full Switch Statement Implementation
CodeNothing now fully supports Switch statements, providing powerful multi-branch control flow capabilities.
🔧 Core Features
- 
Complete Syntax Support switch (expression) { case value1 { // Statements break; }; case value2 { // Statements // Supports fall-through }; default { // Default handler }; };
- 
Multi-Datatype Support - ✅ inttype matching
- ✅ stringtype matching
- ✅ booltype matching
- ✅ floattype matching
- ✅ longtype matching
 
- ✅ 
- 
Advanced Control Flow - ✅ Break statements: Correctly exit switch block
- ✅ Fall-through behavior: Continue to next case without break
- ✅ Default block: Handle unmatched cases
- ✅ Nested switches: Switch inside switch
 
- 
Seamless Language Integration - ✅ Works within functions
- ✅ Supports namespaces
- ✅ Compatible with loops
- ✅ Works with exception handling
- ✅ Supports variables and constants
 
🔧 Technical Implementation
AST Extensions
- Added Statement::Switchstatement type
- Added SwitchCasestruct
- Support for expression matching, statement blocks, and optional default blocks
Parser Enhancements
- Implemented full switch syntax parsing in statement_parser.rs
- Support for switch,case,default,breakkeywords
- Automatic break statement and fall-through behavior detection
Execution Optimizations
- Implemented switch execution logic in statement_executor.rs
- Precise value matching algorithm
- Correct control flow handling (break, fall-through, default)
🐛 Bug Fixes
🔧 Variable Handling Resolution
- Issue: JIT compilation system had bugs causing variable assignment/read errors
- Impact: Affected all variable-dependent operations (including switch matching)
- Solution: Temporarily disabled problematic JIT compilation
- Result: Variable assignment, reading, and comparison now fully functional
📖 Usage Examples
Basic Switch Statement
using lib <io>;  
fn main() : int {  
    choice : int = 2;  
    
    switch (choice) {  
        case 1 {  
            std::println("Selected option 1");  
            break;  
        };  
        case 2 {  
            std::println("Selected option 2");  
            break;  
        };  
        case 3 {  
            std::println("Selected option 3");  
            break;  
        };  
        default {  
            std::println("Invalid selection");  
        };  
    };  
    
    return 0;  
};  
String Switch
status : string = "success";  
switch (status) {  
    case "success" {  
        std::println("Operation succeeded");  
        break;  
    };  
    case "error" {  
        std::println("Operation failed");  
        break;  
    };  
    case "warning" {  
        std::println("Warning detected");  
        break;  
    };  
    default {  
        std::println("Unknown status");  
    };  
};  
Fall-through Example
value : int = 1;  
switch (value) {  
    case 1 {  
        std::println("Executing Case 1");  
        // No break → fall through  
    };  
    case 2 {  
        std::println("Executing Case 2 (may come from fall-through)");  
        break;  
    };  
    case 3 {  
        std::println("This won't execute");  
        break;  
    };  
};  
Nested Switch
category : int = 1;  
subcategory : int = 2;  
switch (category) {  
    case 1 {  
        std::println("Electronics category");  
        
        switch (subcategory) {  
            case 1 {  
                std::println("Phones");  
                break;  
            };  
            case 2 {  
                std::println("Computers");  
                break;  
            };  
            default {  
                std::println("Other electronics");  
            };  
        };  
        break;  
    };  
    case 2 {  
        std::println("Clothing category");  
        break;  
    };  
    default {  
        std::println("Unknown category");  
    };  
};  
📁 Sample Files
Complete examples included in project:
- switch_simple_demo.cn: All switch features demonstration
- switch_complex_example.cn: Complex usage scenarios
🔄 Compatibility
Backward Compatibility
- ✅ Fully compatible with existing code
- ✅ No impact on existing language features
- ✅ Zero modifications required for existing projects
Language Integration
- ✅ Works seamlessly with functions, namespaces, classes
- ✅ Supports usage within loops and conditionals
- ✅ Compatible with exception handling mechanisms
🎯 Performance Optimizations
Execution Efficiency
- ✅ High-performance value matching algorithm
- ✅ Optimized control flow processing
- ✅ Minimal memory allocation
Compilation Optimizations
- ✅ Fast syntax parsing
- ✅ Optimized AST structure
- ✅ Efficient code generation
🔮 Future Plans
Upcoming Features
- 🔄 Reactivate and fix JIT compilation system
- 🔄 Pattern matching extensions for switch
- 🔄 Range matching support (e.g., case 1..10)
- 🔄 Guard condition support (case when condition)
Long-Term Roadmap
- 🔄 Switch expressions (returning values)
- 🔄 Destructuring support
- 🔄 Additional datatype support
🎉 重大功能更新:Switch 语句支持
📋 版本信息
- 版本号: v0.4.0
- 发布日期: 2025-07-24
- 更新类型: 重大功能更新
🚀 新增功能
✨ Switch 语句完整实现
CodeNothing 语言现在完全支持 Switch 语句,提供强大的多分支控制流功能。
🔧 核心特性
- 
完整的语法支持 switch (expression) { case value1 { // 语句块 break; }; case value2 { // 语句块 // 支持 fall-through }; default { // 默认处理 }; };
- 
多数据类型支持 - ✅ int类型匹配
- ✅ string类型匹配
- ✅ bool类型匹配
- ✅ float类型匹配
- ✅ long类型匹配
 
- ✅ 
- 
高级控制流特性 - ✅ Break 语句: 正确跳出 switch 块
- ✅ Fall-through 行为: 没有 break 时继续执行下一个 case
- ✅ Default 块: 处理无匹配的情况
- ✅ 嵌套 Switch: 支持 switch 内嵌套 switch
 
- 
与现有语言特性完美集成 - ✅ 函数内使用
- ✅ 命名空间集成
- ✅ 循环结构配合
- ✅ 异常处理兼容
- ✅ 变量和常量支持
 
🔧 技术实现
AST 扩展
- 新增 Statement::Switch语句类型
- 新增 SwitchCase结构体
- 支持表达式匹配、语句块和可选 default 块
解析器增强
- 在 statement_parser.rs中实现完整的 switch 语法解析
- 支持 switch,case,default,break关键字
- 自动检测 break 语句和 fall-through 行为
执行器优化
- 在 statement_executor.rs中实现 switch 执行逻辑
- 精确的值匹配算法
- 正确的控制流处理(break, fall-through, default)
🐛 Bug 修复
🔧 解决变量处理问题
- 问题: JIT 编译系统在处理变量时存在 bug,导致变量赋值和读取错误
- 影响: 影响所有依赖变量值的操作,包括 switch 语句的值匹配
- 解决方案: 暂时禁用有问题的 JIT 编译,确保变量处理的正确性
- 结果: 变量赋值、读取和比较现在完全正常工作
📖 使用示例
基本 Switch 语句
using lib <io>;
fn main() : int {
    choice : int = 2;
    
    switch (choice) {
        case 1 {
            std::println("选择了选项 1");
            break;
        };
        case 2 {
            std::println("选择了选项 2");
            break;
        };
        case 3 {
            std::println("选择了选项 3");
            break;
        };
        default {
            std::println("无效选择");
        };
    };
    
    return 0;
};
字符串 Switch
status : string = "success";
switch (status) {
    case "success" {
        std::println("操作成功");
        break;
    };
    case "error" {
        std::println("操作失败");
        break;
    };
    case "warning" {
        std::println("警告信息");
        break;
    };
    default {
        std::println("未知状态");
    };
};
Fall-through 示例
value : int = 1;
switch (value) {
    case 1 {
        std::println("执行 Case 1");
        // 没有 break,继续执行下一个 case
    };
    case 2 {
        std::println("执行 Case 2 (可能来自 fall-through)");
        break;
    };
    case 3 {
        std::println("这个不会被执行");
        break;
    };
};
嵌套 Switch
category : int = 1;
subcategory : int = 2;
switch (category) {
    case 1 {
        std::println("电子产品类别");
        
        switch (subcategory) {
            case 1 {
                std::println("手机");
                break;
            };
            case 2 {
                std::println("电脑");
                break;
            };
            default {
                std::println("其他电子产品");
            };
        };
        break;
    };
    case 2 {
        std::println("服装类别");
        break;
    };
    default {
        std::println("未知类别");
    };
};
📁 示例文件
项目中提供了完整的示例文件:
- switch_simple_demo.cn: 包含所有 Switch 功能的演示
- switch_complex_example.cn: 复杂使用场景示例
🔄 兼容性
向后兼容
- ✅ 完全向后兼容现有代码
- ✅ 不影响现有语言特性
- ✅ 现有项目无需修改
语言集成
- ✅ 与函数、命名空间、类等特性完美配合
- ✅ 支持在循环、条件语句中使用
- ✅ 异常处理机制兼容
🎯 性能优化
执行效率
- ✅ 高效的值匹配算法
- ✅ 优化的控制流处理
- ✅ 最小化内存分配
编译优化
- ✅ 快速的语法解析
- ✅ 优化的 AST 结构
- ✅ 高效的代码生成
🔮 未来计划
即将推出的功能
- 🔄 重新启用并修复 JIT 编译系统
- 🔄 Switch 语句的模式匹配扩展
- 🔄 范围匹配支持 (case 1..10)
- 🔄 Guard 条件支持
长期规划
- 🔄 Switch 表达式支持(返回值)
- 🔄 解构匹配
- 🔄 更多数据类型支持
Installation Guide
Download Steps
- Download the following two packages for your operating system:
- Interpreter main package  (codenothing-{OS}.zip)
- Standard library package  (codenothing-all-libraries-{OS}-latest.tar.gz)
 
- Interpreter main package  (
Installation Steps
- Extract both packages
- Create a subfolder named libraryin the interpreter's main directory
- Copy all extracted library files (.dll or .so) into the newly created libraryfolder
Usage
After completing the above steps, you can start using the CodeNothing programming language interpreter.
System Requirements
- Windows/Linux operating system
- Appropriate file extraction tools
安装指南
下载步骤
- 下载适用于您操作系统的以下两个压缩包:
- 解释器本体压缩包(codenothing-{OS}.zip)
- 标准库(library)压缩包(codenothing-all-libraries-{OS}-latest.tar.gz)
 
- 解释器本体压缩包(
安装步骤
- 解压两个压缩包
- 在解释器本体文件夹中创建子文件夹:library
- 将解压出的 library 文件(.dll 或 .so)全部复制到新建的 library文件夹中
使用说明
完成上述步骤后,您就可以开始使用 CodeNothing 编程语言解释器了。
系统要求
- Windows/Linux 操作系统
- 适当的文件解压工具
Full Changelog: CodeNothingCommunity/CodeNothing@v0.3.12...v0.4.0