3 ms·
Point 2 is also for security[1], especially in languages with non-hygienic[2] macro systems such as C. But as another commenter (yissp) already pointed out, eve
by anyfoo 4y ago
Point 2 is also for security[1], especially in languages with non-hygienic[2] macro systems such as C. But as another commenter (yissp) already pointed out, even without macros it can quickly go bad. I once liked omitting blocks in if, while, for etc., but stopped doing it altogether and it now jumps out as a wart to me, too. It's just too risky for too little benefit.
What I disagree with sometimes is whether the block needs to start on a new line. For example I would like to do this:
if (foo = bar) { blah(); }
But my former team was against it, and my current team uses a style enforcement tool (which I do agree with in principle), so I don't.
Point 1 is fine by me and the team: We embrace "tabs for indentation, spaces for alignment", so that fits into the philosophy.
Point 3, i.e. disallowing inline comments, seems ill-conceived and bad to me.
[1] Actually correctness, which often means security.
[2] Or rather a generalization of what "hygienic macro" means.
- dspillett 4y ago> if (foo = bar) { blah(); } I'm happy with that. In fact I usually do that to avoid schoolboy errors when expanding to multiple statements later. It doesn't add much (a few characters, not three lines) and allows for lining up parts (ala my point 1) when there are a couple or more of lines doing very similar (but not so much so they can be usefully reduced to a function/macro).
- anyfoo 4y agoAh. Of course I managed to make a mistake in that minuscule amount of code, = should be == of course. At least a modern compiler would have warned without extra parenthesis.