A cow-orker recently asked me if **XOR** worked on boolean expressions. I told him that it did but I would consider it unreadable and he should use `!=`

instead:

// if either ptr is not null or length is not zero // (but not both) if ( (ptr != NULL)^(length != 0) ) // same but IMO clearer if ( (ptr != NULL)!=(length != 0) )

He then asked whether there is an **implies** operator, after meditating on this for some time I was inspired by the infamous **goes to** operator:

```
int x = 10;
while( x
```**-->** 0 ) { // x goes to 0
printf("%d ", x);
}

~~I’m very proud to present the ~~**implies** operator:

// ptr != NULLimplieslength != 0 if ( (length != 0)<=(ptr != NULL) )

Unfortunately this operator has the quality that it’s read right to left (**X** implies **Y ** → `Y <= X`

) .

**Edit:** Two years after writing this I showed it to a friend who pointed out this is completely wrong, **X** implies **Y ** → `X <= Y`

which pretty much blows the whole thing out of the water. Sorry for wasting your time 😦

Advertisements

phimuemue(13:54:41) :Haha, that’s nice.