Re: [Opengl3dwm-devel] Spacing and indentation ISSUES!
Status: Pre-Alpha
Brought to you by:
zarnick
|
From: <bul...@gm...> - 2006-04-12 19:33:20
|
I agree, I just thought K&R was against spacing, I mean that's the entire
philosophy behind it: save screen space ;)
On Wednesday 12 April 2006 21:55, Alon Dakik wrote:
> Ya, but we are in 2006 now. You can put some spacing in your code and line
> breaks were needed.
>
> if(!blah){doSomething(); doSomethingelse();x++}else
> if(x<y;&&y>z||blah){bleh;}else{ blah; bleh blah;}
>
> is a lot harder to read than
>
> if ( !blah ) {
> doSomething();
> doSomethingelse();
> x++;
> } else if ( x<y && y>z || ! blah) {
> bleh;
> } else {
> blah;
> bleh;
> blah;
> }
>
> On 4/12/06, bul...@gm... <bul...@gm...> wrote:
> > well k&r is very keen on spacing. that's the whole idea behind it, not
> > use space:) it's the 70's 80x25 terminal style.
> >
> > On Wednesday 12 April 2006 21:35, Alon Dakik wrote:
> > > That is not the main point I was trying to bring up, but spacing in
> > > genearl.
> > >
> > >
> > > Errm........................
> > >
> > > On 4/12/06, bul...@gm... <bul...@gm...> wrote:
> > > > erm, is it just me or is that not K&R?
> > > >
> > > > I thought else statements were like this:
> > > >
> > > > }else{
> > > >
> > > > and not like
> > > >
> > > > }else
> > > > {
> > > >
> > > > anyways, doesn't matter I hate it:)
> > > >
> > > > On Wednesday 12 April 2006 07:46, Alon Dakik wrote:
> > > > > Okay, You guys need to put line spaces between statements. I
> >
> > found
> >
> > > > > several obvious bugs that you guys missed.
> > > > >
> > > > > Here is an exact copy of 2 sections in the code from main.c
> > > > >
> > > > >
> > > > >
> > > > > Your code:
> > > > >
> > > > > for(i=0;i<10;i++){
> > > > > Cubes[i].type = i;
> > > > > Cubes[i].size = i*100;
> > > > > Cubes[i].posx = 2+i;
> > > > > Cubes[i].posy = 0.0;
> > > > > Cubes[i].posz = i%3;
> > > > > Cubes[i].blend = TRUE;
> > > > > if(i%2==0){
> > > > > Cubes[i].roty = 1;
> > > > > Cubes[i].ang = ang;
> > > > > }
> > > > > else
> > > > > Cubes[i].blend=FALSE;
> > > > > Cubes[i].selected=FALSE;
> > > > > Cubes[i].id=i;
> > > > > }
> > > > > //Let's start the SDL
> > > > > mode = SDL_OPENGL|SDL_HWPALETTE;
> > > > > if(config.fscreen == TRUE)
> > > > > mode |= SDL_FULLSCREEN;
> > > > > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > > > > if(FMSystem_initSDL(mode,config)!=SUCESS){
> > > > > FMError_perror("FMSystem");
> > > > > exit(errno);
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Here is what I think the above code should look like. Notice you
> > > > > missed brackets on the else statement.
> > > > >
> > > > >
> > > > > for (i=0; i<10; i++ ){
> > > > > Cubes[i].type = i;
> > > > > Cubes[i].size = i*100;
> > > > > Cubes[i].posx = 2+i;
> > > > > Cubes[i].posy = 0.0;
> > > > > Cubes[i].posz = i%3;
> > > > > Cubes[i].blend = TRUE;
> > > > >
> > > > > if ( i%2 == 0 ){
> > > > > Cubes[i].roty = 1;
> > > > > Cubes[i].ang = ang;
> > > > > }
> > > > > else {
> > > > > Cubes[i].blend=FALSE;
> > > > > Cubes[i].selected=FALSE;
> > > > > Cubes[i].id=i;
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > //Let's start the SDL
> > > > > mode = SDL_OPENGL|SDL_HWPALETTE;
> > > > >
> > > > > if(config.fscreen == TRUE)
> > > > > mode |= SDL_FULLSCREEN;
> > > > >
> > > > > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > > > >
> > > > > if(FMSystem_initSDL(mode,config)!=SUCESS){
> > > > > FMError_perror("FMSystem");
> > > > > exit(errno);
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > See how much cleaner that is? and how you missed { } on the else
> > > > > statement? You should write code just like you write your own
> > > > > language. With
> > > > > spaces and line breaks to make it more readable and easier to find
> > > > > bugs.
> > > > >
> > > > > Another example..
> > > > >
> > > > > Your code...
> > > > >
> > > > > while(SDL_PollEvent(&event)){
> > > > > if(event.type==SDL_QUIT)
> > > > > done = TRUE;
> > > > > if(event.type==SDL_KEYDOWN){
> > > > > if(event.key.keysym.sym==SDLK_ESCAPE)
> > > > > done = TRUE;
> > > > > }
> > > > > }
> > > > >
> > > > > Spaced out code:
> > > > >
> > > > >
> > > > > while ( SDL_PollEvent(&event) ) {
> > > > >
> > > > > if( event.type==SDL_QUIT )
> > > > > done = TRUE;
> > > > >
> > > > > if ( event.type==SDL_KEYDOWN ) {
> > > > > if ( event.key.keysym.sym == SDLK_ESCAPE )
> > > > > done = TRUE;
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > That is a whole lot more readable than what is currently in main.c.
> > > > >
> > > > > I'm just trying to add functionality for someone to type in a
> > > > > directory and use my FMDir lib... but right now I have to clean up
> > > > > code :/
> > > >
> > > > -------------------------------------------------------
> > > > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> > > > language
> > > > that extends applications into web and mobile media. Attend the live
> > > > webcast
> > > > and join the prime developer group breaking into this new coding
> > > > territory!
> >
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> >
> > > > _______________________________________________
> > > > Opengl3dwm-devel mailing list
> > > > Ope...@li...
> > > > https://lists.sourceforge.net/lists/listinfo/opengl3dwm-devel
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> > language
> > that extends applications into web and mobile media. Attend the live
> > webcast
> > and join the prime developer group breaking into this new coding
> > territory!
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> > _______________________________________________
> > Opengl3dwm-devel mailing list
> > Ope...@li...
> > https://lists.sourceforge.net/lists/listinfo/opengl3dwm-devel
|