|
Post by bitvast on Aug 8, 2014 13:09:50 GMT 1
@ bitvast: no, it doesn't. The reason is that C will evaluate from left to right. First it sees the 'x > 0' clause, which already is not the case, Hi Peter, But it IS the case that x > 0. I still didn't get any error switching the order, and in fact, this doesn't give an error either: x = 1 y = 0
IF (x/y) > 0 THEN PRINT
The only way I've been able to get the error is to use literals IF (1/0) > 0 THEN PRINT baconshell.bac.c: In function 'main': baconshell.bac.c:60:7: warning: division by zero [-Wdiv-by-zero] if( (1/0) > 0){ ^
|
|
|
Post by Pjot on Aug 8, 2014 13:18:40 GMT 1
Hey bitvast, It was not a good idea of me to answer you at an airport using my tablet Anyway, you are right: during compile time you will not see such an error. You will see the error during runtime because only then the variables have an actual value. As mentioned in the docs, BaCon is a lazy converter. It passes expressions without modification to the compiler. If you explicitly perform a '1/0' then the compiler will complain because these are actual values. With variables you will only get an error during runtime. BR Peter
|
|
|
Post by bitvast on Aug 8, 2014 13:26:13 GMT 1
Thanks Peter for the clarification, I keep forgetting that BaCon is a lazy so and so.
|
|