formatting

Pages: 1234
@Disch,
That looks awful. What's wrong with
AFunctionCall(Param1, Param2, Param3, Param4);
or
1
2
AFunctionCall(Param1, Param2,
		Param3, Param4);

?
Last edited on
It looks better when there's a dozen parameters and some of them are lengthy (some WinAPI calls jump to mind). Cramming them onto 1 or 2 lines results in a very very long line and it's difficult to tell which parameter is which.
Last edited on
I would just extend my second example.
I'm curious. No one of you tab-worshippers write code like this:

1
2
3
4
if     (x == 1) y = 2;
else if(x == 3) y = 5;
else if(x == 7) y = 6;
else            y = 0;

or this:

1
2
3
4
5
switch(x){
   case 2:   y = 12; break;
   case 123: y = 1;  break;
   default:  y = -1; break;
}

or this:

1
2
3
4
x = someFunc(
   /* buf    */ p->get(),
   /* length */ p->getSize(),
   /* param  */ NULL);

?

With tabs, the code like the above tends to get really messy when somebody uses a different tab length. Hell, even if use tabs only at the beginning of lines (what is a stupid complication that gives you nothing), it can still get messy - I've seen retards who used 8-space tabs with 4-space identation. Use a different tab length, and all you can see is a giant piece of ...

Using tabs has simply no advantage over using spaces. In any decent IDE, you don't need to type more. And considering file size is ridiculous - just check how large is all the code you have written during your whole life, and then compare it to the size of movies/music/whatever you keep on your HD. Any conclusions?
I'm curious. No one of you tab-worshippers write code like this:


Did you read some of the previous posts at all? :P

The real issue is when you start trying to use them to make stuff pretty which the resizability is an issue since you can't know how it will be display.


= What you are doing.
I usualy format: 1 tab intend, bracket beloow control.
Did you read some of the previous posts at all? :P

I read pretty much all the posts in this thread, and I'm aware that I only repeat Disch's points. But since almost nobody seems to understand...
I use tabs because it's easier (to delete, it's a 2-key comb. on my editors to revoke an indent in space-mode). I don't tend to try anything too special with my tabs as many people use 2, 4 or 8 size tabs in their editors which would screw it up.

Which refers to my own code, obviously; most people use the spaces and if there's something I've learned it's to stick to the author's conventions.
@Abramus,
It's not that we don't understand, it's that we don't agree. Or do you not understand the concept of people having different viewpoints from yours?
There's this little thing called smart indentation. It appears to be in most IDEs (and notepad++)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
clutter_container_add (CLUTTER_CONTAINER(SMdata->SM_Stage),                
                       SMdata->Full_Screen_Menu_Bar,
                       SMdata->Full_Screen_Task_Bar,
                       SMdata->Full_Screen_Right,
                       SMdata->Full_Screen_Left,
                       SMdata->Full_Screen_Play,
                       SMdata->Full_Screen_Repeat,
                       SMdata->Full_Screen_Stop,
                       SMdata->Full_Screen_DBTop,
                       SMdata->Full_Screen_DBLeft,
                       SMdata->Full_Screen_Colors,
                       SMdata->Full_Screen_DrawOver,
                       SMdata->Full_Screen_ToggleDisplay,
                       SMdata->Full_Screen_Minimize,
                       SMdata->Full_Screen_Hide_Show_Meter,
                       SMdata->Full_Screen_Hide_Show_Browser,
                       SMdata->Full_Screen_FScale,
                       NULL);


Here is an example from an app I'm working on where tabs might mess things up.
Last edited on
Gnome shell extension?
@chrisname
I perfectly understand that people have different viewpoints. Do you not understand that some viewpoints are more valuable/correct than others? Because if your argument is that "it is a taste thing, and we should not discuss tastes", then it is a very poor argument.
Last edited on
Tell me where I said we shouldn't discuss it. You said "nobody seems to understand" and I said that we do understand, we just disagreed.
Chrisname has a proper argument, you can't say an argument isn't relevant because you don't feel strongly about the point or disagree with it.

xander, I don't consider it smart-indentation unless we're talking full-blown MS Visual Studio Indentation. That's smart, but what Notepad++ does is automated but not really that smart and pretty much leaves the user in charge of what indentation is appropriate. And I prefer VS's Indentation abilities, since they generally agree with my idea of how to indent.
closed account (zb0S216C)
I can't believe you lot are arguing over formatting.

Wazzak
OK, I get it now. You understand all the arguments that prove superiority of the space-only approach, but you simply dismiss them. Well, then there is no point discussing anything.
This is how i code a sample from my engine in progress:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
        GXINLINE GXint getEndianness()
        {
            if( sizeof( i16 ) > sizeof( c8 ) )
            {
                i16 s = (i16) 0x0001;
                c8* p = (c8*)&s;

                return ( p[0] == 0x1 )? GX_ENDIAN_BIG : GX_ENDIAN_LITTLE;
            }
            else if( sizeof( i32 ) > sizeof( c8 ) )
            {
                i32 i = (i32) 0x00000001;
                c8* p = (c8*)&i;

                return ( p[0] == 0x1 )? GX_ENDIAN_BIG : GX_ENDIAN_LITTLE;
            }

            return GX_ERR_NOTFOUND;
        }
Last edited on
Why do you use GXINLINE? I've seen people do that before, and I just assume they've got #define MY_INLINE inline somewhere but I don't know why you'd do that.
Last edited on
^lol you are spot-on at least thats what I do right now and I think microsoft does the same in Winapi INLINE (captial letters)

1
2
3
#define GXINLINE inline
#define GXVIRTUAL virtual
//and so one for constant, static, =0 (abstract funct ptr) 


I do it for visibility in my program and consistency's sake. (debugging)

Edit: it also helps portability in certain instances for cross-compiling.

You should check out what OpenGl does as well, its for the same reason.
Last edited on
Pages: 1234