Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

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

And I, for one, still will go on-record as having rejected in code review every piece of logic I have ever encountered (other than in profoundly specialized cases such as device-drivers and parsers) that contained a goto.   And here’s the very-simple reason why:

The program’s internal state, at the point of the label, is solely determined by the internal state at every point that “goes to” that label ... not (only) by the statements which surround it or precede it.   You can, intentionally or worse-yet unintentionally, introduce an error of the most-undebuggable kind at any point in the future ... and if what you did is syntactically acceptable, the compiler won’t say a word of warning to the effect that you just planted a high explosive device with a hair-trigger underneath your foot.

This causes the software complexity meter to spike “infinity,” and for no purpose that cannot be better-achieved in some other way.   Even the “toy” example in the OP is effectively impossible to understand ... even as-written, and only if some other goto is not later added, somewhere, anywhere, anytime.   (Yes, I am intentionally stretching syntactic truth slightly to make a point ...)   You have to think to realize that what this logic is actually doing is if ($arg != 1).

The Perl language evolved a number of constructs, such as last LABELNAME, specifically to accommodate the control-constructs that do indeed occur from time to time in production programs, and to handle them in a way that still affords for efficient code-generation and pragmatic goof-detection.   But goto, except in the edge-cases I previously mentioned, is an unnecessary bad-idea that should never be accepted in production code.   (The edge-case exceptions are not frequent-enough to justify softening the word, “never.”)


In reply to Re: How does 'goto LABEL' search for its label? by sundialsvc4
in thread How does 'goto LABEL' search for its label? by moritz

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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 about the Monastery: (4)
    As of 2014-07-26 15:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (178 votes), past polls