Skip to content

Define defserver's main without eval - #73

Merged
hellerve merged 1 commit into
mainfrom
no-eval
Oct 19, 2026
Merged

hellerve merged 1 commit into
mainfrom
no-eval

Conversation

@hellerve

Copy link
Copy Markdown
Member

defserver built main by calling eval on a (defn main …) form at expansion time. It was the macro's last expression, so the macro now returns that form instead, and the compiler defines main as it would any other expansion. Usage is unchanged.

The reason is portability: a compiler that expands macros ahead of time and keeps compile-time code apart from the program can't eval a static definition in the middle of expansion. On metacarp, defserver failed with unknown compile-time function: App.create. With this change it expands there. web still doesn't build on metacarp, because of an unrelated type-inference error in CacheControl.parse.

Tests. test/web.carp is 408/0 and test/websocket.carp is 155/0. The smoke test and gendocs pass.

@hellerve
hellerve merged commit 918eb34 into main Oct 19, 2026
2 checks passed
@hellerve
hellerve deleted the no-eval branch October 19, 2026 09:10
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