Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] compile time macros #452

Open
b1ek opened this issue Sep 4, 2024 · 0 comments
Open

[Feature] compile time macros #452

b1ek opened this issue Sep 4, 2024 · 0 comments
Assignees

Comments

@b1ek
Copy link
Member

b1ek commented Sep 4, 2024

i think we should allow for some macro-like syntax that is evaluated at compile time to save runtime.

not sure how to implement this, though. i think that they should emit amber code that is inserted into the places where they are called. like this:

macro compile_env(var: Text): Text {
    return text_value(trust $\${var}$);
}

echo compile_env("LANG");

which will evaluate to something like this, assuming that LANG is en on compile time:

echo "en"

text_value() returned a text literal with the value of trust $\${var}$, which was evaluated on compile time


ref #436 , but this issue is for discussing the implementation of macros themselves, not the compile_env!() macro specifically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant