3 ms·
There are plenty of confusing order-of-operation things in C, especially around pointers, but is "&x + 1" really one of them? I basically know nothing about th
by ryanf 16y ago
There are plenty of confusing order-of-operation things in C, especially around pointers, but is "&x + 1" really one of them? I basically know nothing about this subject and it's still pretty clear that the & would take precedence. Would you balk at that expression if x were an int pointer?
- CamperBob 16y agoThis particular case isn't that interesting because if the expression were equivalent to &(x+1) the compiler would complain about taking the address of a non-lvalue. But ryanf, while not defending "that guy" (me), made my point for me: if I have to stop and think about whether -3^5 == -(3^5) because some hotshot didn't consider it manly to use parentheses, nobody wins. If I were writing that expression I'd use (yes, completely unnecessary) parentheses around &a out of habit... the same habit that wouldn't let me write -3^5. Either way, it doesn't burn any more cycles.
- deleted 16y ago[deleted]
- Poiesis 16y agoI don't like guessing. "Yeah, I think it has high precedence" doesn't cut it any more than "Yeah, I think that is supposed to non-null" does. I try not to make assumptions. Does this mean I write code so that it can be read by someone with little experience? Yes, generally. Does this mean I am constantly having to verify my assumptions, as if I don't know anything? Yes, it does. There are some things that I'll take a pass on verifying, but if elevates a problem and everything else checks out, I'm going to seart looking at the parts that I "know" are fine.