Doesn't it just hurt your eyes...

Pages: 12345
Not at all. Forcing the programmer into a specific style is outright oppressive. That's why I don't wear pants on Monday.
closed account (3qX21hU5)
Put a space between the if and () and its perfect LB ; p
closed account (Dy7SLyTq)
just saying, us python programmers never debate about where to put the {} or the semi-colon
That made me laugh, DTSCode.
closed account (Dy7SLyTq)
just for you BHX
@DTS I actually love Python's syntax and indentation, but when Python coders come to C++ temporarily, they often forget that they need braces.

Zereo wrote:
Put a space between the if and () and its perfect LB ; p
How many posts ago did I ask what this style is called and why people use it? Anyway, could you explain this bizarre habit?
I never put a space between the if and () when I code. Most of the books I read about (Bjarne's book included) doesn't seem to do it. It is just a preference thing, but while Zereo was joking I do see other programmers try to force their coding style on others like it is a defacto way of doing it.
Zereo wasn't joking; it is actually a convention someone made up to put spaces before every opening paren. I see no reason, and it makes things harder to read. The only time I put a space before a paren (or brace) is in the special case of inline ctors on declarations:
1
2
int x (4);
int y {7};
This is mainly to emphasize that the syntax is special and not to be confused with a function call or declaration.
Last edited on
closed account (Dy7SLyTq)
i know. i see it all over the internets. its honestly easier to just go through and hit \b a bunch of times
Have a look at this (beautiful) nightmare of spaces before open parens: http://github.com/udp/lacewing/blob/master/src/stream.c
I say it is beautiful because the code is very well written, but it is hard for me to read any of it.
Last edited on
Oh god, how are you people so sensitive to this?
Because it makes a real difference when trying to read and understand the code. Could you imagine reading a book and being distracted because seemingly random letters were capitalized and you didn't know why?

A coding style allows you to emphasize what is important, and if you're emphasizing weird things, it is distracting because people then have to look and understand why it is being emphasized, or if it was even meant to be emphasized. If they think it means something and it didn't, you have just confused a reader.
Last edited on
closed account (Dy7SLyTq)
<cough>once again python</cough>
closed account (3qX21hU5)
Im not sure I can really answer that LB for me I guess it is just something that stuck when I was first learning. I think either Accelerated C++ or C++ Primer 4th edition uses that style which was the first two books I read when I was just beginning so I guess that is where I got it from.
Read through a some old C sources with constructs like:

1
2
3
4
5
6
7
void * newKlElem (frame_size,num_blocks,num_frames,frame_locator)
    size_t frame_size;
    unsigned short num_blocks;
    unsigned short num_frames;
    Kl_frame_locator *locator;
{
    ...


and suddenly things like spaces before an opening paren just don't seem important.
@LB,
1. If you get so fixated an one formatting style that all others become distracting, I suggest that you review your reading skills - flexibility is a thing.
2. Unlike capital letters, whitespaces (the optional ones) don't actually have any meaning. They are there to make different tokens more obviously different. Hence there is no "why" to be confused about.
3. Having in mind that whitespaces differentiate already different tokens, and that whitespace is the most obvious of all delimiters, it is natural that there should be a whitespace before every "(". For example, in the latter case foo (bar, baz); splits at whitespaces into three distinct tokens while foo(bar, baz); introduces a foo(bar, token, which denotes a non-existent special relation of a function name to it's first argument and needs to be further broken up by finding a "(".
@hamsterman
1. When I know that it's just a different style or that it is a beginner with poor formatting skills, I can read it just fine. But when I see something I am not familiar with, I have to take the time to understand what it means and why it is used. So far I have found neither of those answers for the spaces before open parens.
2. You just contradicted yourself - you say they have no meaning, then you say their meaning is to make it more obvious that two tokens are separate. I still don't understand this; in all cases, the two tokens are related, why separate them?
3. The same could be said about putting a space before the comma, before the close paren, before the semicolon, basically a space around every single thing you can put a space around. It doesn't make sense and it slows down reading because, as always, you have to understand why that space is there (syntactic? alignment? reading? compiler extension/limitation?)
void Foo ( bar , baz ) ;
Last edited on
closed account (3qX21hU5)
You got me curious LB so decided to do some research into it and what I have been able to come up with so far is it has something to do with the GNU coding standards.

The consistent treatment of blocks as statements (for the purpose of indentation) is a very distinctive feature of the GNU C code formatting style; as is the mandatory space before parentheses.


http://en.wikipedia.org/wiki/GNU_coding_standards

Still digging for some more exact reasons on why to use it though. For me I guess it just makes things more readable for me.
Last edited on
@LB
1. How is this not just a different style?
2. Nope, syntax is not semantics.
3. The preference of not having a whitespace can likewise be extrapolated to using no spaces at all. And maybe that's fine if you're into it (of course, you're not). The foo(bar, baz); option is actually inconsistent, but before I get into that, I should ask, what does a whitespace mean to you? Do you disagree with my original (2.)? You never really explained why foo(bar, baz); is the better choice, so it's harder for me to prove you wrong.
Pages: 12345