CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

View Poll Results: How often have you used 'goto' in the last 5 years?

Voters
111. You may not vote on this poll
  • I use goto regularly.

    3 2.70%
  • I use goto occasionally.

    8 7.21%
  • I've used goto VERY occasionally.

    34 30.63%
  • I've never used goto at all.

    66 59.46%
Page 9 of 9 FirstFirst ... 6789
Results 121 to 122 of 122
  1. #121
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664

    Re: The grand 'goto' poll

    I'm amazed that this thread is still alive!

    I’m one of three that voted “I use goto regularly”. I still do, in C, for (mostly) cleanup purposes. I strive to be pragmatic about programming and therefore use GOTOs for making my code clearer and easier to understand (yes it really increases the readability). I think I’ve tried to explain this before in this thread, but I don’t know if people noticed it. I really don’t like referring to distinguished people when expressing my opinions, but I’m ready to do an exception this time. Please read the following about the use of goto in the Linux kernel:
    http://kerneltrap.org/node/553?PHPSE...b19cd0de9711b8
    Linus (and others) expresses the usefulness of goto better than I ever will...

  2. #122
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: The grand 'goto' poll

    Quote Originally Posted by j0nas
    I really don’t like referring to distinguished people when expressing my opinions, but I’m ready to do an exception this time. Please read the following about the use of goto in the Linux kernel:
    That's an interesting thread, and although I don't fully agree with Linus's point of view, I found Scott Robert Ladd's contribution to this subject so valuable and to the point that I would like to reproduce it here.
    Quote Originally Posted by Scott Robert Ladd
    I've spent some time looking through the kernel source code, getting a feel
    for the style and process before attempting to contribute something of my
    own. In most ways, the quality of Linux code equals or exceeds that of
    commercial products I've worked on. It may not be perfect, but I'd prefer
    that the maintainers focus on features and bug fixes, not religious issues.

    Your attitude against "goto" is perhaps based upon an excellent but dated
    article, "Goto Considered Harmful", written by Edsger W. Dijkstra, and
    published by the ACM in 1968. (A recent reprint can be found at
    http://www.acm.org/classics/oct95/.) As you can tell from the date, this
    article predates modern programming languages and idioms; it comes from a
    time when Fortran ruled, and before Fortran 77 provided significant tools
    for avoiding spaghetti code.

    A "goto" is not, in and of itself, dangerous -- it is a language feature,
    one that directly translates to the jump instructions implemented in machine
    code. Like pointers, operator overloading, and a host of other "perceived"
    evils in programming, "goto" is widely hated by those who've been bitten by
    poor programming. Bad code is the product of bad programmers; in my
    experience, a poor programmer will write a poor program, regardless of the
    availability of "goto."


    If you think people can't write spaghetti code in a "goto-less" language, I
    can send you some *lovely* examples to disabuse you of that notion.

    Used over short distances with well-documented labels, a "goto" can be more
    effective, faster, and cleaner than a series of complex flags or other
    constructs. The "goto" may also be safer and more intuitive than the
    alternative. A "break" is a goto; a "continue" is a "goto" -- these are
    statements that move the point of execution explicitly.


    That said, I have used exactly two "goto" statements in all the lines of C,
    C++, Fortran 95, and (yes) COBOL I've written since leaving BASIC and
    Fortran IV behind. In one case, a single "goto" doubled the speed of a
    time-critical application; in the other case, "goto" shortens a segment of
    code by half and makes the algorithm much clearer. I would not use a goto
    willy-nilly for the fun of it -- unless I was entering an obfuscated code
    contest

    We keep lowering the bar for technical prowess, it seems; if something has
    the potential to be used "wrong", high-minded designers remove the offending
    syntax rather than find or train competent programmers. This is why Java
    removes pointers (among other things) -- it's not that pointers aren't
    useful or efficient, it's that they require discipline from programmers.


    Just because something is dogma doesn't mean it is absolute truth. If
    anything, dogma should be sniffed quite carefully, since it tends to be
    rather rank if you get close enough. Removing goto is a religious choice,
    not a technical one.


    I could draw parallels with idiotic laws in general society, but this
    message is already marginal for this list.

    ..Scott
    Edit: Bolded the most interesting parts.
    Last edited by gstercken; December 20th, 2004 at 08:33 AM.

Page 9 of 9 FirstFirst ... 6789

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured