Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

There needs to be an answer for "As often/little as needed (but not more or less...)." IMO, "goto" is just another tool in a Perl programmers toolbox. It should be used when/where it's appropriate, and not when it's not.

Having been writing programs since the early 80's, i remember when the whole concept of "goto is evil" arose, not because of goto itself, but because of how many times code would become hard to follow and read (referred to as "spaghetti code"). These days, I do not see that kind of code much, but I do see code which some programmers do all kinds of hard to read/follow "tricks", *just* to avoid the use of goto. This makes no sense to me given the whole concept of "avoid goto" arose from the idea that such code was hard to read/follow. Why does making the code hard to read/follow at the *other* extreme make such code "better?" It doesn't.

When you develop in assembly language, for example, it's nearly impossible to avoid the use of jump/branch statements (upon which goto is based/modeled) in non-trivial code, and still write code which is fast and small--and yes, easy to follow. To do the same thing without any form of branch/jump/"goto", would require a lot of extra confusing code, or the use of many more subroutines ..and the extra overhead of calling them! It's faster and less code to simply change the current execution address than it is to.. save the registers/flags/call data/other state data, allocated stack space, transfer to a new routine, load the data back, process it, save it all back again, return from the routine, restore everything again, and resume execution. Sounds like a complicated mess like that? It is!

This whole issue, to me, is similar to the issue of code comments/documentation. I've seen far more people who do not comment/document--or just as bad, people who add comments when they're not necessary because the code is already self-evident.

IMO, we need less people preaching "Never use 'goto'!" and more people preaching "Program intelligently; Use what you need and keep it clean, simple, and understandable."


In reply to Re: Number of times I've used goto in Perl by Casteele
in thread Number of times I've used goto in Perl by vroom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (5)
    As of 2019-03-22 15:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      How do you Carpe diem?





      Results (113 votes). Check out past polls.

      Notices?