|
| 1 | +# ProXPL v1.3.0: The "Pattern Power" Release |
| 2 | + |
| 3 | +**Target Release Date:** Q2 2026 |
| 4 | +**Status:** Planned |
| 5 | +**Codename:** Pattern Power |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 🌟 Overview |
| 10 | + |
| 11 | +ProXPL v1.3.0 focuses on delivering three long-awaited language features — **Pattern Matching**, **Enums**, and **Generics** — alongside stabilizing the Foreign Function Interface (FFI) and fixing critical bugs identified in v1.2.0. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## ✨ New Features |
| 16 | + |
| 17 | +### 1. Pattern Matching (`match` / `case`) |
| 18 | +First-class pattern matching with exhaustiveness checking. |
| 19 | + |
| 20 | +```javascript |
| 21 | +func describe(value) { |
| 22 | + match (value) { |
| 23 | + case 0 => print("Zero"); |
| 24 | + case 1..10 => print("Small number"); |
| 25 | + case n if n > 100 => print("Large: " + to_string(n)); |
| 26 | + case "hello" => print("Greeting!"); |
| 27 | + case [first, ...rest] => print("List starting with " + to_string(first)); |
| 28 | + case {name, age} => print(name + " is " + to_string(age)); |
| 29 | + case _ => print("Unknown"); |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +**Implementation Details:** |
| 35 | +- New keywords: `match`, `case`, `_` (wildcard) |
| 36 | +- Range patterns: `1..10`, `'a'..'z'` |
| 37 | +- Guard clauses: `case n if n > 0` |
| 38 | +- Destructuring patterns for lists and dictionaries |
| 39 | +- Exhaustiveness checking at compile time |
| 40 | +- New AST nodes: `EXPR_MATCH`, `PATTERN_LITERAL`, `PATTERN_RANGE`, `PATTERN_WILDCARD`, `PATTERN_DESTRUCTURE` |
| 41 | +- New opcodes: `OP_MATCH`, `OP_MATCH_RANGE`, `OP_DESTRUCTURE` |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +### 2. Enums (Algebraic Data Types) |
| 46 | +Type-safe enumerated types with associated values. |
| 47 | + |
| 48 | +```javascript |
| 49 | +enum Color { |
| 50 | + Red, |
| 51 | + Green, |
| 52 | + Blue, |
| 53 | + Custom(r, g, b) |
| 54 | +} |
| 55 | + |
| 56 | +enum Result { |
| 57 | + Ok(value), |
| 58 | + Err(message) |
| 59 | +} |
| 60 | + |
| 61 | +func process() { |
| 62 | + let status = Result.Ok(42); |
| 63 | + |
| 64 | + match (status) { |
| 65 | + case Result.Ok(val) => print("Success: " + to_string(val)); |
| 66 | + case Result.Err(msg) => print("Error: " + msg); |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +**Implementation Details:** |
| 72 | +- New keyword: `enum` |
| 73 | +- Variant constructors with associated values |
| 74 | +- Integration with pattern matching for exhaustive checks |
| 75 | +- Type checker enforcement: all variants must be handled |
| 76 | +- New AST nodes: `DECL_ENUM`, `EXPR_ENUM_VARIANT` |
| 77 | +- New opcodes: `OP_ENUM`, `OP_ENUM_VARIANT`, `OP_IS_VARIANT` |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +### 3. Generics (Parameterized Types) |
| 82 | +Type-safe generic programming without code duplication. |
| 83 | + |
| 84 | +```javascript |
| 85 | +func identity<T>(value: T): T { |
| 86 | + return value; |
| 87 | +} |
| 88 | + |
| 89 | +class Stack<T> { |
| 90 | + let items: List<T> = []; |
| 91 | + |
| 92 | + func push(item: T) { |
| 93 | + push(this.items, item); |
| 94 | + } |
| 95 | + |
| 96 | + func pop(): T { |
| 97 | + return pop(this.items); |
| 98 | + } |
| 99 | + |
| 100 | + func peek(): T { |
| 101 | + return this.items[length(this.items) - 1]; |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +let intStack = new Stack<int>(); |
| 106 | +intStack.push(42); |
| 107 | +``` |
| 108 | + |
| 109 | +**Implementation Details:** |
| 110 | +- Angle bracket syntax: `<T>`, `<K, V>` |
| 111 | +- Constraint bounds (future): `<T: Comparable>` |
| 112 | +- Monomorphization at compile-time for AOT path |
| 113 | +- Type erasure for VM/bytecode path |
| 114 | +- Type checker extensions for generic unification |
| 115 | +- New AST nodes: `TYPE_GENERIC`, `DECL_GENERIC_FUNC`, `DECL_GENERIC_CLASS` |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +### 4. FFI Stability |
| 120 | +Stabilize the Foreign Function Interface introduced in v0.7.0. |
| 121 | + |
| 122 | +- **Type marshaling**: Full support for `int`, `float`, `string`, `bool`, `void*` parameter types |
| 123 | +- **Callback support**: Pass ProXPL functions as C callbacks |
| 124 | +- **Struct interop**: Read/write C struct fields from ProXPL |
| 125 | +- **Multi-library loading**: Load multiple `.dll`/`.so` files simultaneously |
| 126 | +- **Error handling**: Graceful handling of missing symbols and library load failures |
| 127 | +- **Documentation**: Complete FFI guide with platform-specific examples |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## 🐛 Bug Fixes |
| 132 | + |
| 133 | +### Critical |
| 134 | +| ID | Description | Component | Severity | |
| 135 | +|----|-------------|-----------|----------| |
| 136 | +| BUG-101 | **Token buffer overflow**: `main.c` uses fixed `Token tokens[4096]` arrays — large programs crash silently | Lexer/main.c | 🔴 Critical | |
| 137 | +| BUG-102 | **REPL version string outdated**: Shows `v1.0` instead of current version | main.c:34 | 🟡 Low | |
| 138 | +| BUG-103 | **PRM `run` parser mismatch**: `dispatchPRM` parses `project.pxcf` using TOML-style `key = "value"` but `manifest.c` uses `key: "value"` | PRM/main.c | 🔴 Critical | |
| 139 | +| BUG-104 | **`prm test` is a no-op**: Always prints "Tests passed! (0 failures)" without actually running tests | PRM/main.c:374 | 🟠 High | |
| 140 | +| BUG-105 | **`prm watch` not implemented**: Prints stub message and exits | PRM/main.c:377 | 🟠 High | |
| 141 | +| BUG-106 | **`.gitignore` file corruption**: Lines 137-141 contain NUL bytes (UTF-16 encoding corruption) | .gitignore | 🟡 Medium | |
| 142 | +| BUG-107 | **GC mark-and-sweep incomplete**: Listed as complete in PHASE_PLAN.md but noted as "not yet implemented" in CHANGELOG.md | GC/gc.c | 🟠 High | |
| 143 | +| BUG-108 | **Integer precision**: Runtime uses NaN-boxed doubles limiting integer precision to 53 bits | value.h/vm.c | 🟡 Medium | |
| 144 | + |
| 145 | +### Improvements |
| 146 | +- Enhanced error messages with contextual suggestions ("Did you mean...?") |
| 147 | +- REPL history and tab-completion support |
| 148 | +- Dynamic token buffer allocation (replace fixed `Token[4096]` arrays) |
| 149 | +- Standardized `project.pxcf` parser across all code paths |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## 📊 Compiler Changes |
| 154 | + |
| 155 | +| Component | Change | |
| 156 | +|-----------|--------| |
| 157 | +| **Lexer** | New tokens: `TOKEN_MATCH`, `TOKEN_ENUM`, `TOKEN_CASE`, `TOKEN_WILDCARD` | |
| 158 | +| **Parser** | New AST nodes for pattern matching, enums, and generics | |
| 159 | +| **Type Checker** | Generic type unification, exhaustiveness checking, enum variant validation | |
| 160 | +| **Bytecode Gen** | New opcodes for match dispatch, enum construction, destructuring | |
| 161 | +| **VM** | Runtime support for enum values, pattern matching, generic type tags | |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## 📈 Performance Goals |
| 166 | + |
| 167 | +- Startup time: < 3ms (cold start) |
| 168 | +- Pattern match dispatch: O(1) via computed jump tables |
| 169 | +- Enum variant check: single-instruction comparison |
| 170 | +- No regression in existing benchmark suite |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## 🔧 Breaking Changes |
| 175 | + |
| 176 | +- None planned. Full backward compatibility with v1.2.0 code. |
| 177 | + |
| 178 | +--- |
| 179 | + |
| 180 | +## 📦 Migration Guide |
| 181 | + |
| 182 | +No migration required from v1.2.0. All new features are additive. |
| 183 | + |
| 184 | +--- |
| 185 | + |
| 186 | +*ProXPL v1.3.0 — Making types work for you, not against you.* |
0 commit comments