[Suggestion] constant declaration
I work on a colored text function but color code in bash is not explicit
fun text(message: Text, color: Num, style: Num) {
unsafe $echo -e "\e[{style as Text};{color as Text}m{message}\e[0m"$
}
text("test", 32, 3)
this output italic green text. i think is more comprehensive if we can write :
text("test", _bash_foreground_green_, _bash_italic_)
maybe in future external lib can declare constant
im confused. is this about creating a const keyword or about helping with your code?
Sorry is about creating a const keyword, my code work fine
@CymDeveloppement so you propose to introduce constants. I don't see any reason not to do add it to Amber. Not that much important for now though. I'll mark it as a Stable Release issue.
this should be implemented as the let keyword, but locks the future variable changes
i would propose this being implemented as a function that is called each time the value is retrieved - it ensures runtime safety as well as compile checks
const FIVE = 5
const_FIVE() {
return 5
}
it depend if it must be accessible from bash,
If no, compiler can just replace all occurence of five constant by 5
but in bash function is not a constant, this script :
function test__0_v0 {
echo "OK"
};
test__0_v0 ;
__AMBER_FUN_test0_v0__6=${__AMBER_FUN_test0_v0};
echo ${__AMBER_FUN_test0_v0__6} > /dev/null 2>&1
function test__0_v0 {
echo "OK2"
};
test__0_v0 ;
output :
OK
OK2
in bash constant can be declared with readonly five=5
My proposition:
- target is bash: use
readonlysyntax - target is sh: replace all occurrences with the constant
i think maintain maximum of compatibility with sh is good
Now we have @CymDeveloppement functions like shell_set can be a solution for this task?