[–] rwolf 13y ago ↗ The title is missing a >. Should be "-->" [–] QuarkSpark 13y ago ↗ For some reason it changes the "-->" back to "--" I tried many times/ways to include the entire operator before giving up & just posting it.. [–] sukuriant 13y ago ↗ What about > ?
[–] QuarkSpark 13y ago ↗ For some reason it changes the "-->" back to "--" I tried many times/ways to include the entire operator before giving up & just posting it.. [–] sukuriant 13y ago ↗ What about > ?
[–] The_Egg_Man 13y ago ↗ Could someone break this down and explain it to me? [1] It looks hilariously atrocious yet interesting at the same time.[1]: http://stackoverflow.com/questions/1642028/what-is-the-name-... [–] ctdonath 13y ago ↗ #define as ;while ... do printf("n is %d\n", n) as ( n --> 0); Parses to (white space adjusted for clarity): do printf("n is %d\n", n); while ( n-- > 0); [–] dmbass 13y ago ↗ The preprocessor replaces the macro "as" with ";while" creating a do-while loop. do { printf("%d",x); } while (x-- > 0); [–] stephen_g 13y ago ↗ Basically, somebody sees some code with two operators (decrement and less than) with no whitespace between them and thinks it's a single operator.The answer that shows it with the brackets is probably the clearest: while ((x--) > 0) { ... } The compiler sees that as the same as (x--> 0)So it checks if x is more than zero and then decrements it each loop iteration.
[–] ctdonath 13y ago ↗ #define as ;while ... do printf("n is %d\n", n) as ( n --> 0); Parses to (white space adjusted for clarity): do printf("n is %d\n", n); while ( n-- > 0);
[–] dmbass 13y ago ↗ The preprocessor replaces the macro "as" with ";while" creating a do-while loop. do { printf("%d",x); } while (x-- > 0);
[–] stephen_g 13y ago ↗ Basically, somebody sees some code with two operators (decrement and less than) with no whitespace between them and thinks it's a single operator.The answer that shows it with the brackets is probably the clearest: while ((x--) > 0) { ... } The compiler sees that as the same as (x--> 0)So it checks if x is more than zero and then decrements it each loop iteration.
[–] sukuriant 13y ago ↗ This looks mostly like a function that sacrificed readability for brevity, to the detriment of at least one reader.
10 comments
[ 3.4 ms ] story [ 37.4 ms ] thread[1]: http://stackoverflow.com/questions/1642028/what-is-the-name-...
The answer that shows it with the brackets is probably the clearest:
The compiler sees that as the same as (x--> 0)So it checks if x is more than zero and then decrements it each loop iteration.