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] access compile time environment variables #436

Open
b1ek opened this issue Sep 1, 2024 · 2 comments
Open

[Feature] access compile time environment variables #436

b1ek opened this issue Sep 1, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request feature proposal

Comments

@b1ek
Copy link
Member

b1ek commented Sep 1, 2024

Is your feature request related to a problem? Please describe.
see #431

Describe the solution you'd like
i think that we should add rust-like compile time macros, like env!() in this case which should enable the user to access compile time environment variables.

for the env!() macro, i suggest the following syntax:

fun env(variable: Text, default: Text): Text {
    // returns the specified variable if it exists, and default if it is set and the env variable is not available.
    // if default value is not set and variable is not available, it will throw a compile time error
}

which should be used like this:

const compile_commit = env!("COMPILE_COMMIT", "unknown");

which should be compiled to something like this (assuming COMPILE_COMMIT is set to a8c3083f:

declare -r compile_commit = "a8c3083f"

Describe alternatives you've considered
#431 (comment)

@b1ek b1ek added enhancement New feature or request feature proposal labels Sep 1, 2024
@b1ek b1ek self-assigned this Sep 1, 2024
@Mte90
Copy link
Member

Mte90 commented Sep 2, 2024

IF those are compiler variables I think that env can be confusing with the env functions we have in stdlib.
Maybe compiler_env is better.

@b1ek
Copy link
Member Author

b1ek commented Sep 3, 2024

IF those are compiler variables I think that env can be confusing with the env functions we have in stdlib. Maybe compiler_env is better.

yeah, i think that would work too. i suggested env!() because it is the same that rust has

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature proposal
Projects
None yet
Development

No branches or pull requests

2 participants