Skip to content

feat: self-host cond macro, remove Expr::Cond from compiler - #156

Merged
thsfranca merged 1 commit into
mainfrom
feat/self-hosted-cond
Mar 21, 2026
Merged

feat: self-host cond macro, remove Expr::Cond from compiler#156
thsfranca merged 1 commit into
mainfrom
feat/self-hosted-cond

Conversation

@thsfranca

Copy link
Copy Markdown
Owner

Summary

  • Define cond as a variadic defmacro in stdlib/prelude.vx that expands to nested if expressions
  • Remove Expr::Cond, CondClause, parse_cond, expand_cond, and check_cond from the compiler
  • cond is no longer a special parser form — it parses as a regular function call and expands via the prelude macro
  • Add macro expansion to the typechecker check_source test helper so cond-related tests work through the full pipeline

Net result: -283 lines, +45 lines — the compiler gets simpler while cond keeps working identically.

Test plan

  • All 551 tests pass
  • cargo clippy clean
  • (cond test1 val1 test2 val2 :else default) expands correctly to nested if
  • (cond) with no clauses produces nil
  • Non-bool cond test still errors at type-check time
  • examples/let-and-cond.vx compiles successfully
  • Interpreter cond_expression test passes end-to-end

Define cond as a variadic defmacro in the prelude that expands
to nested if expressions. Remove Expr::Cond, CondClause, parse_cond,
expand_cond, and check_cond from the compiler — cond is no longer
a special form. Add macro expansion to typechecker test helper so
cond tests work through the full pipeline.
@thsfranca
thsfranca enabled auto-merge (squash) March 21, 2026 23:34
@thsfranca
thsfranca merged commit a3502c4 into main Mar 21, 2026
2 checks passed
@thsfranca
thsfranca deleted the feat/self-hosted-cond branch March 21, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant