Richard Stallman says to write functions like this

This is a discussion on Richard Stallman says to write functions like this within the Tech Board forums, part of the Community Boards category; Hi. Richard Stallman recommends to write functions like this: int function() not like this: int function(); Can anyone tell me ...

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

    Richard Stallman says to write functions like this

    Hi. Richard Stallman recommends to write functions like this:


    int
    function()

    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.

    thanks.
    Remember that all that code you write turns into this:

    0100100100110010010011100100111001001
    0010100100100001001111100010010010010 ....

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

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,854
    http://en.wikipedia.org/wiki/Indentation_style
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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 08:40 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    I only write template functions using two lines for the header
    Code:
    template <class t> 
    int run(t aType)
    {
    }

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >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
    Location
    Ontario, Canada
    Posts
    2,718
    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
    Posts
    8,893
    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!
    CornedBee

    "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, 05:20 PM
  2. Replies: 12
    Last Post: 10-23-2006, 08:45 AM
  3. Some humour...
    By Stan100 in forum A Brief History of Cprogramming.com
    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, 11:56 AM
  5. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 07:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21