Short circuit evaluation: yes or no?
Posted: Wed Nov 01, 2023 8:34 am
Hi to everyone!
Someone asked if ugBASIC supports short circuit evaluation.
On Wikipedia there is a complete explanation.
In a short, the following argument in a boolean expression is executed or evaluated only if the first argument does not suffice to determine the value of the expression. I.e. if we have an AND operator, and the first term is false, we do not need to calculate the second term.
From my point of view, this is a very thorny discussion.
Conceptually, short circuit evaluation is a functionality introduced by some medium-level languages, such as C. The reason why it was introduced is linked to the fact that it allows obtaining notable optimizations, at the cost of avoiding the execution of specific functions. The problem with introducing this type of optimization is that the functions that you avoid performing could have "side effects", and in ugBASIC, side effects are quite common, due to the fact that it is a stackless language.
What is your opinion?
Someone asked if ugBASIC supports short circuit evaluation.
On Wikipedia there is a complete explanation.
In a short, the following argument in a boolean expression is executed or evaluated only if the first argument does not suffice to determine the value of the expression. I.e. if we have an AND operator, and the first term is false, we do not need to calculate the second term.
From my point of view, this is a very thorny discussion.
Conceptually, short circuit evaluation is a functionality introduced by some medium-level languages, such as C. The reason why it was introduced is linked to the fact that it allows obtaining notable optimizations, at the cost of avoiding the execution of specific functions. The problem with introducing this type of optimization is that the functions that you avoid performing could have "side effects", and in ugBASIC, side effects are quite common, due to the fact that it is a stackless language.
What is your opinion?