Thread: Richard Stallman says to write functions like this

  1. #1
    Linux is where it's at movl0x1's Avatar
    Join Date
    May 2007

    Richard Stallman says to write functions like this

    Hi. Richard Stallman recommends to write functions like this:


    not like this:

    int function();

    Can anyone tell me what the difference is to the compiler.

    I personally use the latter, but like the look of the GNU style declaration.

    Remember that all that code you write turns into this:

    0010100100100001001111100010010010010 ....

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    The compiler doesn't care.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Pick a style, and apply it consistently.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Ah, now I know the name of my style - BSD/KNF style (or similar). I never use two-line headers.
    Last edited by maxorator; 05-31-2007 at 07:40 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    I only write template functions using two lines for the header
    template <class t> 
    int run(t aType)

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >Can anyone tell me what the difference is to the compiler.
    Differences in formatting are for you, not the compiler. That particular convention is designed for code outside of a modern IDE where to search for a function definition, all you have to do is search for the function name at column 0. Any legitimate call will not be at column 0 if you use proper indentation. However, that convention really isn't necessary these days with advanced code editors.

    In fact, a lot of older conventions that save you from your stupidity and make working with code easier are obsolete with newer compilers and editors.
    My best code is written with the delete key.

  7. #7
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Ontario, Canada
    Prelude, I think you're forgetting that stupidity evolves just as quickly (or possibly even more quickly) compared to compilers and editors.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Considering how often I'm hacking with minimal tools on the command line, I don't think conventions that make code more readable for such tools are ever obsolete.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Functions
    By aznballerlee in forum C++ Programming
    Replies: 3
    Last Post: 10-24-2006, 04:20 PM
  2. Replies: 12
    Last Post: 10-23-2006, 07:45 AM
  3. Some humour...
    By Stan100 in forum A Brief History of
    Replies: 8
    Last Post: 11-06-2003, 10:25 PM
  4. Attaching functions to a class/struct
    By VirtualAce in forum Tech Board
    Replies: 2
    Last Post: 08-04-2003, 10:56 AM
  5. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM