fun call(key){
if key == "some" {
return some()
} else {
return other()
}
}
fun some(){
echo "SOME"
return call("END")
}
fun other(){
echo "OTHER"
return call("END")
}
main {
let keyword = "some"
echo call(keyword)
}
$ amber ./sample.ab
ERROR
Function 'some' does not exist
at ./sample.ab:3:16
2| if key == "some" {
3| return some()
4| } else {
It seems that when the function call tries to call functions some and other, which are defined later, an error occurs. If the called function is not defined before the calling function, it results in an error. This prevents writing recursive processes across multiple functions.
The following code produces an error:
It seems that when the function
call
tries to call functionssome
andother
, which are defined later, an error occurs. If the called function is not defined before the calling function, it results in an error. This prevents writing recursive processes across multiple functions.