Thread: [Opengl3dwm-devel] Spacing and indentation ISSUES!
Status: Pre-Alpha
Brought to you by:
zarnick
|
From: Alon D. <alo...@gm...> - 2006-04-12 04:46:59
|
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=3D0;i<10;i++){
Cubes[i].type =3D i;
Cubes[i].size =3D i*100;
Cubes[i].posx =3D 2+i;
Cubes[i].posy =3D 0.0;
Cubes[i].posz =3D i%3;
Cubes[i].blend =3D TRUE;
if(i%2=3D=3D0){
Cubes[i].roty =3D 1;
Cubes[i].ang =3D ang;
}
else
Cubes[i].blend=3DFALSE;
Cubes[i].selected=3DFALSE;
Cubes[i].id=3Di;
}
//Let's start the SDL
mode =3D SDL_OPENGL|SDL_HWPALETTE;
if(config.fscreen =3D=3D TRUE)
mode |=3D SDL_FULLSCREEN;
FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
if(FMSystem_initSDL(mode,config)!=3DSUCESS){
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=3D0; i<10; i++ ){
Cubes[i].type =3D i;
Cubes[i].size =3D i*100;
Cubes[i].posx =3D 2+i;
Cubes[i].posy =3D 0.0;
Cubes[i].posz =3D i%3;
Cubes[i].blend =3D TRUE;
if ( i%2 =3D=3D 0 ){
Cubes[i].roty =3D 1;
Cubes[i].ang =3D ang;
}
else {
Cubes[i].blend=3DFALSE;
Cubes[i].selected=3DFALSE;
Cubes[i].id=3Di;
}
}
//Let's start the SDL
mode =3D SDL_OPENGL|SDL_HWPALETTE;
if(config.fscreen =3D=3D TRUE)
mode |=3D SDL_FULLSCREEN;
FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
if(FMSystem_initSDL(mode,config)!=3DSUCESS){
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=3D=3DSDL_QUIT)
=09done =3D TRUE;
if(event.type=3D=3DSDL_KEYDOWN){
=09if(event.key.keysym.sym=3D=3DSDLK_ESCAPE)
=09 done =3D TRUE;
}
}
Spaced out code:
while ( SDL_PollEvent(&event) ) {
if( event.type=3D=3DSDL_QUIT )
=09done =3D TRUE;
if ( event.type=3D=3DSDL_KEYDOWN ) {
=09 if ( event.key.keysym.sym =3D=3D SDLK_ESCAPE )
=09 done =3D 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 :/
|
|
From: <bul...@gm...> - 2006-04-12 18:25:42
|
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 :/
|
|
From: Alon D. <alo...@gm...> - 2006-04-12 18:35:48
|
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=3D0;i<10;i++){
> > Cubes[i].type =3D i;
> > Cubes[i].size =3D i*100;
> > Cubes[i].posx =3D 2+i;
> > Cubes[i].posy =3D 0.0;
> > Cubes[i].posz =3D i%3;
> > Cubes[i].blend =3D TRUE;
> > if(i%2=3D=3D0){
> > Cubes[i].roty =3D 1;
> > Cubes[i].ang =3D ang;
> > }
> > else
> > Cubes[i].blend=3DFALSE;
> > Cubes[i].selected=3DFALSE;
> > Cubes[i].id=3Di;
> > }
> > //Let's start the SDL
> > mode =3D SDL_OPENGL|SDL_HWPALETTE;
> > if(config.fscreen =3D=3D TRUE)
> > mode |=3D SDL_FULLSCREEN;
> > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > if(FMSystem_initSDL(mode,config)!=3DSUCESS){
> > 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=3D0; i<10; i++ ){
> > Cubes[i].type =3D i;
> > Cubes[i].size =3D i*100;
> > Cubes[i].posx =3D 2+i;
> > Cubes[i].posy =3D 0.0;
> > Cubes[i].posz =3D i%3;
> > Cubes[i].blend =3D TRUE;
> >
> > if ( i%2 =3D=3D 0 ){
> > Cubes[i].roty =3D 1;
> > Cubes[i].ang =3D ang;
> > }
> > else {
> > Cubes[i].blend=3DFALSE;
> > Cubes[i].selected=3DFALSE;
> > Cubes[i].id=3Di;
> > }
> >
> > }
> >
> > //Let's start the SDL
> > mode =3D SDL_OPENGL|SDL_HWPALETTE;
> >
> > if(config.fscreen =3D=3D TRUE)
> > mode |=3D SDL_FULLSCREEN;
> >
> > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> >
> > if(FMSystem_initSDL(mode,config)!=3DSUCESS){
> > 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=3D=3DSDL_QUIT)
> > done =3D TRUE;
> > if(event.type=3D=3DSDL_KEYDOWN){
> > if(event.key.keysym.sym=3D=3DSDLK_ESCAPE)
> > done =3D TRUE;
> > }
> > }
> >
> > Spaced out code:
> >
> >
> > while ( SDL_PollEvent(&event) ) {
> >
> > if( event.type=3D=3DSDL_QUIT )
> > done =3D TRUE;
> >
> > if ( event.type=3D=3DSDL_KEYDOWN ) {
> > if ( event.key.keysym.sym =3D=3D SDLK_ESCAPE )
> > done =3D 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=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Opengl3dwm-devel mailing list
> Ope...@li...
> https://lists.sourceforge.net/lists/listinfo/opengl3dwm-devel
>
|
|
From: Alon D. <alo...@gm...> - 2006-04-12 18:38:29
|
Errmmm.. BTW
"}else{" is not K & R according to what you typed before.
if (x < 0) {
printf("Negative");
negative(x);
} else {
printf("Positive");
positive(x);
}
That is K&R... Notice the spaces between braces? Cleaner, easier to read,
and is the standard. Spacing is needed for clarity and sanity.
On 4/12/06, Alon Dakik <alo...@gm...> 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=3D0;i<10;i++){
> > > Cubes[i].type =3D i;
> > > Cubes[i].size =3D i*100;
> > > Cubes[i].posx =3D 2+i;
> > > Cubes[i].posy =3D 0.0;
> > > Cubes[i].posz =3D i%3;
> > > Cubes[i].blend =3D TRUE;
> > > if(i%2=3D=3D0){
> > > Cubes[i].roty =3D 1;
> > > Cubes[i].ang =3D ang;
> > > }
> > > else
> > > Cubes[i].blend=3DFALSE;
> > > Cubes[i].selected=3DFALSE;
> > > Cubes[i].id=3Di;
> > > }
> > > //Let's start the SDL
> > > mode =3D SDL_OPENGL|SDL_HWPALETTE;
> > > if(config.fscreen =3D=3D TRUE)
> > > mode |=3D SDL_FULLSCREEN;
> > > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > > if(FMSystem_initSDL(mode,config)!=3DSUCESS){
> > > 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=3D0; i<10; i++ ){
> > > Cubes[i].type =3D i;
> > > Cubes[i].size =3D i*100;
> > > Cubes[i].posx =3D 2+i;
> > > Cubes[i].posy =3D 0.0;
> > > Cubes[i].posz =3D i%3;
> > > Cubes[i].blend =3D TRUE;
> > >
> > > if ( i%2 =3D=3D 0 ){
> > > Cubes[i].roty =3D 1;
> > > Cubes[i].ang =3D ang;
> > > }
> > > else {
> > > Cubes[i].blend=3DFALSE;
> > > Cubes[i].selected=3DFALSE;
> > > Cubes[i].id=3Di;
> > > }
> > >
> > > }
> > >
> > > //Let's start the SDL
> > > mode =3D SDL_OPENGL|SDL_HWPALETTE;
> > >
> > > if(config.fscreen =3D=3D TRUE)
> > > mode |=3D SDL_FULLSCREEN;
> > >
> > > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > >
> > > if(FMSystem_initSDL(mode,config)!=3DSUCESS){
> > > 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=3D=3DSDL_QUIT )
> > > done =3D TRUE;
> > > if(event.type=3D=3DSDL_KEYDOWN){
> > > if(event.key.keysym.sym=3D=3DSDLK_ESCAPE)
> > > done =3D TRUE;
> > > }
> > > }
> > >
> > > Spaced out code:
> > >
> > >
> > > while ( SDL_PollEvent(&event) ) {
> > >
> > > if( event.type=3D=3DSDL_QUIT )
> > > done =3D TRUE;
> > >
> > > if ( event.type=3D=3DSDL_KEYDOWN ) {
> > > if ( event.key.keysym.sym =3D=3D SDLK_ESCAPE )
> > > done =3D 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=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> > _______________________________________________
> > Opengl3dwm-devel mailing list
> > Ope...@li...
> > https://lists.sourceforge.net/lists/listinfo/opengl3dwm-devel
> >
>
>
|
|
From: <bul...@gm...> - 2006-04-12 18:39:20
|
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
|
|
From: Alon D. <alo...@gm...> - 2006-04-12 18:55:27
|
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 us=
e
> 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=3D0;i<10;i++){
> > > > Cubes[i].type =3D i;
> > > > Cubes[i].size =3D i*100;
> > > > Cubes[i].posx =3D 2+i;
> > > > Cubes[i].posy =3D 0.0;
> > > > Cubes[i].posz =3D i%3;
> > > > Cubes[i].blend =3D TRUE;
> > > > if(i%2=3D=3D0){
> > > > Cubes[i].roty =3D 1;
> > > > Cubes[i].ang =3D ang;
> > > > }
> > > > else
> > > > Cubes[i].blend=3DFALSE;
> > > > Cubes[i].selected=3DFALSE;
> > > > Cubes[i].id=3Di;
> > > > }
> > > > //Let's start the SDL
> > > > mode =3D SDL_OPENGL|SDL_HWPALETTE;
> > > > if(config.fscreen =3D=3D TRUE)
> > > > mode |=3D SDL_FULLSCREEN;
> > > > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > > > if(FMSystem_initSDL(mode,config)!=3DSUCESS){
> > > > 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=3D0; i<10; i++ ){
> > > > Cubes[i].type =3D i;
> > > > Cubes[i].size =3D i*100;
> > > > Cubes[i].posx =3D 2+i;
> > > > Cubes[i].posy =3D 0.0;
> > > > Cubes[i].posz =3D i%3;
> > > > Cubes[i].blend =3D TRUE;
> > > >
> > > > if ( i%2 =3D=3D 0 ){
> > > > Cubes[i].roty =3D 1;
> > > > Cubes[i].ang =3D ang;
> > > > }
> > > > else {
> > > > Cubes[i].blend=3DFALSE;
> > > > Cubes[i].selected=3DFALSE;
> > > > Cubes[i].id=3Di;
> > > > }
> > > >
> > > > }
> > > >
> > > > //Let's start the SDL
> > > > mode =3D SDL_OPENGL|SDL_HWPALETTE;
> > > >
> > > > if(config.fscreen =3D=3D TRUE)
> > > > mode |=3D SDL_FULLSCREEN;
> > > >
> > > > FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> > > >
> > > > if(FMSystem_initSDL(mode,config)!=3DSUCESS){
> > > > 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=3D=3DSDL_QUIT)
> > > > done =3D TRUE;
> > > > if(event.type=3D=3DSDL_KEYDOWN){
> > > > if(event.key.keysym.sym=3D=3DSDLK_ESCAPE)
> > > > done =3D TRUE;
> > > > }
> > > > }
> > > >
> > > > Spaced out code:
> > > >
> > > >
> > > > while ( SDL_PollEvent(&event) ) {
> > > >
> > > > if( event.type=3D=3DSDL_QUIT )
> > > > done =3D TRUE;
> > > >
> > > > if ( event.type=3D=3DSDL_KEYDOWN ) {
> > > > if ( event.key.keysym.sym =3D=3D SDLK_ESCAPE )
> > > > done =3D 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=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> > > _______________________________________________
> > > 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=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Opengl3dwm-devel mailing list
> Ope...@li...
> https://lists.sourceforge.net/lists/listinfo/opengl3dwm-devel
>
|
|
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
|