rant

Matlab WTF: Inconsistent short-circuit behavior of logical operators

24 September, 2009 - 09:38
Categories:

I just stumbled on another reason to dislike Matlab: the stupid inconsistency of the short-circuit behavior of the elementwise logical operators: the statement

fun(2) | fun(9999)

does not short-circuit, so both fun(2) and fun(9999) are executed, but when used in an if or while expression like

if fun(2) | fun(9999); end;

the expression does short-circuit, meaning that only fun(2) is executed.

I know, you also have the || and && operators, which are defined as short circuiting operators, but the inconsistency with the | and & operators is just stupid, if not evil.

Read more...