feat: add list support to C backend and improve compile workflow

C Backend Lists:
- Add LuxList type (dynamic array with void* boxing)
- Implement all 16 list operations: length, isEmpty, concat, reverse,
  range, take, drop, head, tail, get, map, filter, fold, find, any, all
- Higher-order operations generate inline loops with closure calls
- Fix unique variable names to prevent redefinition errors

Compile Command:
- `lux compile file.lux` now produces a binary (like rustc, go build)
- Add `--emit-c` flag to output C code instead
- Binary name derived from source filename (foo.lux -> ./foo)
- Clean up temp files after compilation

Documentation:
- Create docs/C_BACKEND.md with full strategy documentation
- Document compilation pipeline, runtime types, limitations
- Compare with Koka, Rust, Zig, Go, Nim, OCaml approaches
- Outline future roadmap (evidence passing, Perceus RC)
- Fix misleading doc comment (remove false Perceus claim)
- Update OVERVIEW.md and ROADMAP.md to reflect list completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 11:02:26 -05:00
parent d284ee58a8
commit 909dbf7a97
5 changed files with 954 additions and 87 deletions

View File

@@ -181,7 +181,6 @@ fn processAny(x: Int @latest): Int = x // any version
### Planned (Not Yet Fully Implemented)
- **C Backend Lists**: Closures and pattern matching work, lists pending
- **Auto-migration Generation**: Migration bodies stored, execution pending
---
@@ -234,7 +233,6 @@ Quick iteration with type inference and a REPL.
| Limitation | Description |
|------------|-------------|
| **Limited C Backend** | Functions, closures, ADTs work; lists pending |
| **No Package Manager** | Can't share/publish packages yet |
| **New Paradigm** | Effects require learning new concepts |
| **Small Ecosystem** | No community packages yet |
@@ -371,13 +369,13 @@ Values + Effects C Code → GCC/Clang
- ✅ Console.readLine and Console.readInt
- ✅ C Backend (basic functions, Console.print)
- ✅ C Backend closures and pattern matching
- ✅ C Backend lists (all 16 operations)
- ✅ Watch mode / hot reload
- ✅ Formatter
**In Progress:**
1. **C Backend Lists** - List operations pending
2. **Schema Evolution** - Type system integration, auto-migration
3. **Error Message Quality** - Context lines shown, suggestions partial
1. **Schema Evolution** - Type system integration, auto-migration
2. **Error Message Quality** - Context lines shown, suggestions partial
**Planned:**
4. **SQL Effect** - Database access