Skip to main content
15 events
when toggle format what by license comment
Apr 25, 2017 at 10:56 comment added Pharap @isanae FWIW it makes sense to me. if(expression) statement; is logical because it resembles a simple sentence. It's equally logical to ensure that brace pairs are vertically aligned. K&R's sytem of having the start brace at the end of a line and the end brace at the start of a line seems far more backwards by comparison.
Apr 24, 2017 at 17:01 comment added Viktor Toth @isanae I developed/maintained 100,000+ line projects in C/C++ (and prior to that, Algol-60 and Simula-67). Based on that, I find that not putting an opening curly brace on its own line but insisting that if (a>b) c=d; must occupy two lines (or three, with curly braces!) makes little sense to me. (Note that I am not trying to pile arbitrary statements on the same line. These are simple conditionals.) But as I said, I realize these are subjective judgment calls. What I do with my own projects is my business. When I work collaboratively, I am disciplined and adhere to the group's standards.
Apr 24, 2017 at 16:45 comment added isanae @ViktorToth The fact that you find K&R difficult to read but like putting statements on the same line as an if makes no sense to me.
Apr 24, 2017 at 16:42 comment added Viktor Toth @isanae I usually put statements on separate lines, but I sometimes make exceptions for simple things like return or printing some text. I consider this a judgment call. What irritates me more is the current prevailing practice of not putting opening curly braces on a separate line. This, in my (strictly personal) opinion affects readability and makes it that much harder to visually match opening and closing braces. In the end, though, a lot of these things are subjective. When I work on a collaborative project, I just stay disciplined and follow the project's standards (if any).
Apr 24, 2017 at 16:01 comment added isanae @BenVoigt Out of curiosity, which debugger do you know of that isn't line-based?
Apr 24, 2017 at 10:54 comment added isanae @BenVoigt Not all of us have the privilege of working with such a unicorn :(
Apr 24, 2017 at 6:00 comment added Ben Voigt @isanae: That's not necessary with a good debugger, which can place breakpoints on any full-expression no matter where in the line it appears.
Apr 24, 2017 at 1:22 comment added isanae @ViktorToth Then at least put statements on different lines. That would allow you to put breakpoints on individual branches of ifs.
Apr 23, 2017 at 13:11 comment added Viktor Toth That is a good point but I respectfully disagree. Over the decades (I've been writing code since the 1970s) I came to despise excessive curly braces. Beyond being (in my admittedly personal opinion) unnecessary pedantic, they also make the code harder to read, as it is spread out over more real estate, harder to see all at once. Yes, when there is a chance that there will be more code inserted, I use curly braces as well, or when there are too many levels of indentation. But when I judge that they can be omitted, I happily do so.
Apr 23, 2017 at 9:29 comment added Cody Gray It isn't a correctness issue, but since this is a code review site, I must say that I would prefer to see more curly braces in your code. Even though I understand how it works, seeing a for loop immediately after an if, without the introduction of any scope, always makes me do I double-take. It also makes maintenance substantially more difficult.
Apr 23, 2017 at 1:02 comment added Viktor Toth Good point. Edited.
Apr 23, 2017 at 1:01 history edited Viktor Toth CC BY-SA 3.0
Null pointer check in C version
Apr 23, 2017 at 0:45 comment added Pharap The C version needs a null pointer check.
Apr 22, 2017 at 23:13 review First posts
Apr 22, 2017 at 23:35
Apr 22, 2017 at 23:13 history answered Viktor Toth CC BY-SA 3.0