[Feature] Call Amber function from Bash script
This right now is impossible as the function gets renamed with the compilation... Maybe we need a flag to compile with keeping the same function names.
I think it should be possible to do so per individual function, while keeping the prefix/renaming for everything else.
It should make sense to not rename functions and should be fine. Reading the bash generated it is just that, I think that the renaming is used only for the error reporting because includes the line of the original Amber script. Maybe for that is better to use a sourcemap or refer to the original amber script.
It is something that @Ph0enixKM can explain better then me.
Function renaming is because we have template functions and the fact that you can declare the same function with the same name in multiple files in Amber. We don't store the position of where in code is the function declared though.
I think that we can easily implement this idea you provided with some env keyword:
env fun foo(name: Text) {
echo "Hello {name}!"
}
source amber-code.sh
foo "Adam"
# Output: Hello Adam!
@Ph0enixKM why env? seems very out of place for me
Maybe interpreter so in base it is compiled for sh, bash does automatically?
Using the nameof change suggested in #673, one could write $my_exported_fun() \{ {nameof my_fun} }$ to export a function, which in turn could be made into an stdlib function export() if support for functions as arguments is added.
This would lead to code looking like this:
pub fun my_fun() {
echo "exported"
}
export(my_fun)