FAQ: Someone know where to use "continue"

This is a discussion on FAQ: Someone know where to use "continue" within the FAQ Board forums, part of the General Programming Boards category; Originally posted by Shiro I'm very curious if someone can show me an example of an algorithm using continue which ...

  1. #46
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Originally posted by Shiro

    I'm very curious if someone can show me an example of an algorithm using continue which is faster than not using continue. I've never seen such, but it doesn't mean that it doesn't exist. So if someone knows such example, I'd be thankfull to learn from it.
    As I said before, in my tests continue beats out not using continue. For those who are interested here is the code I used during my last test.
    Attached Files Attached Files

  2. #47
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    For an accurate test, you really should use identical loops. Furthermore, you need to make sure in each case you end up testing for the same exact thing. Without it, the test is hardly accurate. IE: Just because you write code to use the word 'continue' doesn't mean you're using the same number of checks.

    [edit]
    To reply to the above post, no, it wasn't directly specificly at you. It was more of an "in general" observation of these types of threads. They in the just end up as threads where one person argues their point, another argues theirs, and neither one will ever convince the other because in some situations, there is no real "right way". That's mainly what that comment was about.
    [/edit]

    Quzah.
    Last edited by quzah; 12-09-2002 at 04:24 PM.
    Hope is the first step on the road to disappointment.

  3. #48
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by vVv
    Personally, I can't remember the last time I used nested ``continue'''s or even a single ``goto'' - yet I don't think they should be avoided by all costs.
    And that's my entire point.

    As for the comment regarding checks, if you look at the provided code, you'll notice that the "for" loops are different on two or three of the checks. Additionally, they end up checking for different values.

    If you're trying to compare one method versus another, your tests should be as near identical as possible. That's the point. (Look at the attached .c file, you'll see what I'm talking about.) It's unfair to compare tests if the tests themselves do not have the same standards or criteria.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #49
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Preach on Quzah! And that is the bottom line. My tests merely show that using continue is faster sometimes, but a program doesn't always call for it. Also, there are a number of other optimizations that can be made before using break or continue. My point was not to show that you need to use break to make a fast loop, rather, my point was to show an example of where a break statement is best.

  5. #50
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    Originally posted by Magos
    I agree, but can someone mention any good usage for goto?
    goto is very dangerous in programming structure. this could make your programming more confusing.... just like looping there and looping here... and then going there and then going here... it's not recommended to use it anyway.

  6. #51
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    Originally posted by quzah
    We aren't talking about self-modifying code here. Once compiled, your program is done. All checks are finished, unless it's a scriptible application, in which case, this whole point is moot anyway.

    As such, there is no scenario I can envision where your example would be valid. Furthremore, why couldn't I just add another && sitution?

    This isn't a holy war over the evils of continue. By all means, do whatever you want. Just make your code readable and clear so the next person that has to maintain your code knows what the hell is going on. That's the whole point.

    In everything you code, make sure the next idiot that follows you knows what's going on. Code as if an idiot is going to have to read your code after you're done with it.

    Quzah.
    i agree to quzah's comment. however, using the bad structure could make the whole program more confusing. i try to avoid using "GOTO, continue, break" if necessary. all of the certain things that i mention is bad structure in my mind. if let say that if ppl wan to use with this statement, never mind. it's ok for that ppl, but if they use it in certain time, the whole program look like untidy, unstructure. This is not included on the flowchart.

    && shouldn't hardly disturb on the exe time. i just add a variable to control it. am i right ?

  7. #52
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    another point is...
    :: a good structure on program that made by the programmer usually follow on flowchart. most of the book, said that "break, goto, continue " is not recommended to place it on the program -- it's bad structure, you may find the the prove from : -
    -- c how to program (deitel)
    -- approch using c structure
    -- how to design in c

    i'm not argue that "break, goto, continue" is can't used it among others. everybody have freedom to choose which one is better. but i would prefer for my own design by adding another variable and control to loop, that's all. hope you dont mind on my comment.

  8. #53
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    Actually, "continue" is convenient to use, for example, in a for:next loop, when you want the loop to iterate again without executing some additional code within the loop.

    As for 'goto', the primary reason to use goto is for peformance. In many cases you can eliminate a test entirely or have an algorithm be much tighter and more direct by judicious use of a goto.

    There is nothing wrong with either one. To say you should never use either one is like telling someone they should never pick their nose because it looks uncouth. Well I'm sorry, but there _is_ an appropriate time to pick your nose. Period. End of Discussion.


    [rant = on]

    I just wish a portion of people on this board would spend a little more time actually getting concepts and understanding what is going on in the machine, as opposed to getting hung up on truly pointless hyperbole. I watch too many people get "lost" on syntactic, grammatic, and "purist" issues, and they never actually get to concentrate on what's important: implementing _logic_.

    Because that's what development is really about-- implementing logic in software.
    It is not the spoon that bends, it is you who bends around the spoon.

  9. #54
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    well... sayeh, depend on it. what you prefer on is depend on situation.

    i did tell this URL to my friends, you know one of my friend (expert in c program) did say ?
    " .... depend on situation what type of program, i would rather choose your way (that's mean he agree on my program with adding && and variable) than using "break' because that kind of program is bad structure...."

    2 of c program lecture did say...
    " .... break's bad structure, avoid using it .... "

    ok there guys, that's all about end of thread , and thanks for getting this challenging posted. wishing this thread will closed anyway.

    :: depend on what you prefer to use, may use own style ::

  10. #55
    Registered User
    Join Date
    Oct 2002
    Posts
    46

    Talking

    No point in arguing any more... Some people drank the cool-aid and some people didn't.

  11. #56
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    yeah, every ppl have diff mind and ideals , right no wonder there's will conflict with other co-worker on their project programming. LOL

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wiki FAQ
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 192
    Last Post: 04-29-2008, 02:17 PM
  2. Help with FAQ
    By JoshG in forum Game Programming
    Replies: 19
    Last Post: 10-29-2002, 07:31 PM
  3. FAQ Check/Lock
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-15-2002, 12:21 PM

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