In some languages, a |= b is even cooler. "a" is set to the value of "b" IF AND ONLY IF a does not already have a value that avaluates to "true". This can be used as a simple mechanism to get defaults into your code.
As a software engineer who works on embedded systems a fair amount, I like being able to use a|=b to mean "do a bitwise OR of a with b and store the result in a". The use you mention doesn't make logical sense to me. Of course, to get the result you want in C, all I need is: "a ? true : a=b;" It's slightly longer, but it gets the trick done ;)
oh, and the reason it probably w on't compile is due tot he maximal munch strategy used by C parsers. Basically, the parser will interpret it as i++ ++ + i; and throw an error on the ++ operator just hanging there in space.
Comments 7
"a" is set to the value of "b" IF AND ONLY IF a does not already have a value that avaluates to "true". This can be used as a simple mechanism to get defaults into your code.
Reply
Reply
also, a++ is the same as a += 1
Reply
Reply
i+++++i; is a valid statement in C.
however it probably won't compile.
it SHOULD be written as i++ + ++i;
but even better would be to use parentheses.
even better than that would be to not do something that fucking obnoxious and obfuscated.
Reply
Reply
Reply
Leave a comment