Here is a snippet from https://github.com/anura-engine/anura/blob/55bc02244f0faba5e0831578a3c1c9a82e7bf569/src/formula_function.cpp#L923-L931:
FUNCTION_DEF(if, 2, -1, "if(a,b,c)")
const int nargs = static_cast<int>(NUM_ARGS);
for(int n = 0; n < nargs-1; n += 2) {
const bool result = EVAL_ARG(n).as_bool();
if(result) {
return EVAL_ARG(n+1);
}
}
As we can see, if there is more than one condition evaluating as true, only the then-expression corresponding to the first condition evaluating as true is returned.
Actually, only the first condition evaluating as true gets to be evaluated as true.
Meta discussing FFL, (1) would it make sense that the expression should evaluate all the conditions and return a list of all then-expressions corresponding to true conditions, as long as the inside of the whole conditional expression is free from execution triggers (bind_command
, ;
, etc.)? Also (2) does this exist already (obviously with a different signature)?