Skip to content

Define the generated getters and setters without eval - #15

Merged
hellerve merged 1 commit into
masterfrom
no-eval
Oct 22, 2026
Merged

hellerve merged 1 commit into
masterfrom
no-eval

Conversation

@hellerve

@hellerve hellerve commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Five Luax macros (luax--def-maybe-get and the global and field setters and getters) defined their functions by calling eval on a (do (doc …) (defn …)) form at expansion time. Each was the macro's last expression, so the macros now return that form instead, and the compiler defines the functions as it would any other expansion. Usage is unchanged. The eval in Lua.setup stays: it runs system-include and add-cflag, not definitions.

The reason is portability, as in suite#3 and web#73: 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. metacarp is one, and lua failed there because its compile-time evaluator has no meta-set!, which doc needs. With this change the library compiles on metacarp.

Tests. On the reference compiler all five test files pass (76, 86, 10, 22 and 25 tests), as do lint, format and gendocs. On metacarp the main suite passes, 76/76.

@hellerve
hellerve merged commit f63d7ca into master Oct 22, 2026
2 checks passed
@hellerve
hellerve deleted the no-eval branch October 22, 2026 10:37
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