But you, who uses indentation?

A few days ago I was discussing how it indents code Ansi / C and therefore it is possible to use the same style in different languages.
Obviously, the indentation is like the mother, and each has its advantages and extols the know: my mother is untouchable!


Today, looking for information on wikipedia I came across this page: Indent Style where he discusses the most common techniques for indentation, here's a small summary:

* K & R style

  / / ...
     x < 0 ) { if (x <0) {
         "Negative" ) ; printf ("Negative");
         ; negative (x);
     { Else {}
         "Positive" ) ; printf ("Positive");
         ; positive (x);
     } 
 




* Allman style (bsd in Emacs)

  x == y ) while (x == y)
 {
     something ();
     somethingelse ();
 }
 finalthing (); 




* BSD KNF style

  x == y ) { while (x == y) {
     something ();
     somethingelse ();
 }
 finalthing (); 




* Whitesmiths style

  x == y ) while (x == y)
     {
     something ();
     somethingelse ();
     }

 finalthing (); 




* GNU style

  x == y ) while (x == y)
   {
     something ();
     somethingelse ();
   }
 finalthing (); 




* Horstmann style

  x == y ) while (x == y)
 ; {Something ();
     somethingelse ();
     / / ...
     x < 0 ) if (x <0)
     ( "Negative" ) ; {Printf ("Negative");
         ; negative (x);
     }
     else
     ( "Positive" ) ; {Printf ("Positive");
         ; positive (x);
     }
 }
 finalthing (); 




* Pico style

  stuff (n):
 {X: 3 * n;
   y: DoStuff (x);
   y + x} 




* Banner style

  function1 () {
   DoStuff
   do more stuff
   }

 function2 () {
   etc.
   } 



And what you used?

Posted under Technology

This post was written by admin on November 4, 2008

Tags: , ,

Other Posts

8 Comments so far

  1. pine November 5, 2008 6:31 pm

    But with the missing languages ​​like python or the indentation obliged ... Cobol. ;)

  2. Raphael C. November 5, 2008 6:44 pm

    Configuration:
    Tab in void spaces (I hate the character \ t)
    Indentation of 2 characters

    Styles:
    GNU Style for all code
    Pico Style for short methods of boilerplate code (type setter / getter and the like)

  3. Matthew November 5, 2008 9:14 pm

    GNU Style all his life, also because I started with Pascal :)

  4. Lisa November 5, 2008 9:17 pm

    BSD style for if / while and the like! Instead the body functions Allman style.
    This however is it called? It is not in list

    if (condition) {
    something ();
    Else {}
    something_else ();
    }

    Sometimes I use it.

  5. Lisa November 5, 2008 9:18 pm

    Ooops sorry, I had missed the first in the list : D
    Fix also the first to comment!

  6. Freddy November 6, 2008 12:04 am

    I am old, and K & R. :)
    Even if the code tends to be moved too far right ...

  7. Max November 6, 2008 12:35 am

    if (condition)
    {
    ....
    ....
    ....
    Else {}
    ....
    ....
    ....
    }

  8. Rollopack November 10, 2008 8:51 am

    K & R style

Leave a Comment

Name (required)

Email (required)

Website

Comments