[Feature] access compile time environment variables
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 https://github.com/amber-lang/amber/issues/431#issuecomment-2323256429
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.
IF those are compiler variables I think that
envcan be confusing with the env functions we have in stdlib. Maybecompiler_envis better.
yeah, i think that would work too. i suggested env!() because it is the same that rust has