r/programming • • Oct 19 '09

djb

http://www.aaronsw.com/weblog/djb
96 Upvotes

129 comments sorted by

View all comments

Show parent comment

1

u/TheNewAndy Oct 20 '09

I find it difficult to believe that there was a compiler that didn't short circuit && (you generally have to do more work this way).

However, as a style thing it can make complete sense. Use "if" when order matters, and use "&&" when it doesn't. Just like you might have a "map" function, and a "foreach" function in a language, where the "foreach" is identical, but doesn't return anything. While you could use "map" and ignore the result, it can be clearer to show that you really don't care about the result.

2

u/[deleted] Oct 22 '09

Heck, when I wrote a compiler for my compilers class (20 years ago. Wow) we had to do short-circuiting of && and ||. If a compiler didn't do that I'm not sure I'd trust it to get anything event moderately interesting correct.