C writing style

Started by
37 comments, last by vicviper 20 years, 3 months ago
Just to add my terrible style to this post:
void func(){    int myvar=func2();    do{        func3();        func4();    }while((myvar=func2())!=0);}


"Stop trying to hit me and hit me!"
Emil Johansen- SMMOG AI designerhttp://smmog.com
Advertisement
I prefer my nippley brackets, sorry braces, to be on their own line. White space is your friend.

quote:Original post by davepermen
the best idea of phyton is, that style is grammar. there is just one way.


Not sure I understand you correctly but in python, style is the only thing you''re sure will always be similar. Style makes the application. Or breaks it depending on how you see it.

ex:
def foo( bar )   doSomething   doSomethingElsefoo( baz ) 

It''s rather fun to use but actually Ruby is even better IMHO.


[Cyberdrek | the last true sorcerer | Spirit Mage - mutedfaith.com][ Administrator & WebMaster GuLSE]
[Cyberdrek | ]
quote:Well, importing into Visual C++ and auto-formatting works well.

No it doesn''t.

It''s completely inadequate.

quote:The difficulty of finding a good prettyprinter is indicative of the difficulties inherent in parsing arbitrary block-structured languages, IMO. Which is why they should die, among other things.

Not really, no.

One of the reasons python liberally uses :s (i.e. it doesn''t just let the indentation do the work) is because it makes it easier to parse, after all.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
quote:Original post by sBibi
int           main(int argc,char** argv) {int i, j;     char *asd;  for(i=0;i<5; i++)  {  for  ( j = -1; j >-10 ; j++ )    if (!(asd= do_stuff  (argc,argv ,asd)))    return(-1);   printf("%s\n" ,asd);}return 0;}    


i like that guy's lack of style. i however prefer to cut down on useless whitespace, eg.

int main(int argc,char** argv){int i,j;char *asd;for(i=0;i<5;i++) {for(j=-1;j>-10;j++)if(!(asd=do_stuff(argc,argv ,asd)))return(-1);printf("%s\n",asd);}return 0;}

[EDIT: Your "preference" for no whitespace - particularly putting everything on a single line - makes the page unreadably wide.]

[edited by - necromancer_df on January 13, 2004 8:45:48 PM]

[edited by - Oluseyi on January 14, 2004 6:01:04 PM]
did you even read my post? or only looked at the "code" and decided to post a line long enough to mess up the entire page?

In a ''C writing style'' topic, why are people suggesting ''Just use Python''?

Just swan dive into some molten lava -- OK problem solved -- no more C writing style issues. This is my advice.


.z
while(a){ while(b) { ++b; }++a;} 
quote:
In a ''C writing style'' topic, why are people suggesting ''Just use Python''?

Just swan dive into some molten lava -- OK problem solved -- no more C writing style issues. This is my advice.


Possibly because C (and personally I''d add C++) is almost always the wrong choice, just as swan diving into molten lava is.

This topic is closed to new replies.

Advertisement