goto label not recomended?

This is a discussion on goto label not recomended? within the C Programming forums, part of the General Programming Boards category; I have heard that the use of... goto label ...is not recomended? Why is that?...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    63

    Red face goto label not recomended?

    I have heard that the use of...

    goto label

    ...is not recomended? Why is that?
    You cantīt teach an old dog new tricks.

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    I have heard that the use of...

    goto label

    ...is not recomended?
    I heard that too. The main reason for not using goto: it can lead to bad maintanble code.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    63
    Originally posted by Shiro
    I heard that too. The main reason for not using goto: it can lead to bad maintanble code.
    So it has nothing to do with technical reasons then?
    You cantīt teach an old dog new tricks.

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by electrolove
    So it has nothing to do with technical reasons then?
    No. In fact, all other loops are buildt upon simple goto:s. The reason to avoid goto is that unreadable (unfollowable) spaghetti code is so easily made with it.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Magos is right, in some situations, local jumps are in fact a faster alternative. But, he's right. When your code is filled to the rim with goto's, you know what happens? People start scrolling up...and scrolling down...and scrolling over just to read your code. Then people start complaining, calling lawyers, holding their breath, leaving the toilet seat up..and it's a mess.

    Not using goto's, and planning out your code, usually leads to an elegant piece of nicely flowing art.

    Maybe you can find something interesting here:
    http://www.google.com/search?hl=en&l...=Google+Search
    The world is waiting. I must leave you now.

  6. #6
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    I don't recommend labels (goto) because it makes your code dirty and more difficult to maintence.

  7. #7
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    My opinion is that you should only use goto if it makes the code easier to read. This is VERY RARE , the only time i would even consider using it is to escape a deeply nested structure if rewriting it without gotos would be more confusing.
    Personally, i've been writing code for a while and I have never had to use a goto.

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by beege31337
    i've been writing code for a while and I have never had to use a goto.
    And you never have to. It's only ment to speed things up and
    for easier reading. But don't use it exessively.

  9. #9
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,255
    My old computing teacher told me that if I ever used goto in my code I would be arrested. Same goes for dividing by zero. Care to test the theory?

  10. #10
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by SMurf
    My old computing teacher told me that if I ever used goto in my code I would be arrested. Same goes for dividing by zero. Care to test the theory?

    Let's lock up carmack then shall we?

  11. #11
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    This has been discussed many times before... please do a search if you want to know more.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  2. Label within a label?
    By Manaxter in forum C# Programming
    Replies: 0
    Last Post: 11-04-2006, 08:49 AM
  3. helpppp
    By The Brain in forum C Programming
    Replies: 1
    Last Post: 07-27-2005, 07:05 PM
  4. Need some help with a basic tic tac toe game
    By darkshadow in forum C Programming
    Replies: 1
    Last Post: 05-12-2002, 04:21 PM
  5. Goto Label
    By unanimous in forum C++ Programming
    Replies: 10
    Last Post: 04-08-2002, 12:22 AM

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