Boolean short circuiting
BlitzMax Forums/BlitzMax Programming/Boolean short circuiting
| ||
Hello all I was just messing about to test whether bmax short-circuits boolean expressions, and it seems that it does: Does anyone know if this is intentional, and if so can I rely on it always being in the language, and on left to right ordering like C? It's just that it's so damned handy! Ian C |
| ||
Does anyone know if this is intentional, and if so can I rely on it always being in the language, and on left to right ordering like C? Yes, it's intentional and yes, it will always evaluate left to right. |
| ||
WOOOOOOOOOOOOOOOOW - i do not know this... i think this is the same how this works in C++... test this in bb3d and bbmax. in bb3d this create a error - in blitzmax not! nice Type test Field val:Int EndType Local xxx:test If xxx<>Null And xxx.val=1 Then Print "COOL" Print "OK" |
| ||
That's very useful. Also, you can just use "If xxx" instead of "If xxx<>Null" I think. |
| ||
that's old future. |
| ||
Fantastic news Mark! Cheers for that. And MrCredo it is very powerful and just the same as C++ works (and C# for that matter)... Rather than having to nest lots of if's for cheap over expensive operations, just do: if CheapCollisionCheck() and ExpensiveCollisionCheck() ... And you've done a handy bit of opimisation as ExpensiveCollisionCheck() won't be called if CheapCollisionCheck() was false :-) Ian C |