Windows

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Change in "goto" behavior

    12 answers - 628 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I have noticed a change in behavior in "goto" statements recently. Whereas a statement like "goto PLACE;" would work fine no matter where "PLACE:" was in my code, I've noticed that scripts that used to work are now failing at the "goto" statement.
    I can probably work out an example if needed, but the general question is: have any restrictions been put on "goto" recently? What are the real criteria needed to be satisfied for the destination to be successfully found?
    Thanks,
    Dave
    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:
  • No.1 | | 643 bytes | |

    Dave Ressler wrote:
    I have noticed a change in behavior in "goto" statements recently.
    Whereas a statement like "goto PLACE;" would work fine no matter where
    "PLACE:" was in my code, I've noticed that scripts that used to work are
    now failing at the "goto" statement.

    Guess what Dave - I don't believe you. ;)

    I can probably work out an example if needed, but the general question
    is: have any restrictions been put on "goto" recently? What are the real
    criteria needed to be satisfied for the destination to be successfully
    found?

    Definitely provide an example - I don't think you can.
  • No.2 | | 1194 bytes | |

    Message
    From: "Dave Ressler" <perl (AT) nettenna (DOT) com>
    To: "Perl List" <perl-win32-users (AT) listserv (DOT) ActiveState.com>
    Sent: Wednesday, July 13, 2005 11:06 AM
    Subject: Change in "goto" behavior

    I have noticed a change in behavior in "goto" statements recently. Whereas
    a statement like "goto PLACE;" would work fine no matter where "PLACE:" was
    in my code, I've noticed that scripts that used to work are now failing at
    the "goto" statement.

    I can probably work out an example if needed, but the general question is:
    have any restrictions been put on "goto" recently? What are the real
    criteria needed to be satisfied for the destination to be successfully
    found?

    Check 'perldoc -f goto'. If that doesn't answer the query, post a simple
    example that demonstrates the problem.

    The 'goto' documentation has changed a little from 5.6 to 5.8. I don't know
    whether that represents a change in functionality, or just a re-wording.

    Cheers,
    Rob

    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:
  • No.3 | | 902 bytes | |

    Why on earth are you using a goto statement? They are pernicious.

    HL

    7/12/05, Dave Ressler <perl (AT) nettenna (DOT) comwrote:

    I have noticed a change in behavior in "goto" statements recently. Whereas
    a statement like "goto PLACE;" would work fine no matter where "PLACE:" was
    in my code, I've noticed that scripts that used to work are now failing at
    the "goto" statement.
    I can probably work out an example if needed, but the general question
    is: have any restrictions been put on "goto" recently? What are the real
    criteria needed to be satisfied for the destination to be successfully
    found?
    Thanks,
    Dave

    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:

    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:
  • No.4 | | 2763 bytes | |

    At 08:30 AM 7/13/2005, Hugh Loebner wrote:
    >Why on earth are you using a goto statement? They are pernicious.


    We have a goto in our code. I hate it, but there just isn't a good "switch"
    or "case" statement in Perl yet (I think I've heard that it's planned), and
    the following just isn't efficient enough for us:

    if ($op = 'thisop') {
    }
    elsif ($op = 'thatop') {
    }

    There are hundreds of possible values for $op. Anyway, I don't know how
    many people are aware of it, but the destination of a "goto" can be a
    variable, e.g.

    goto $op;

    thisop:
    do_this();
    thatop:
    do_that();

    course, you then have to prevent the fall through from the code for
    thisop: to the code for thatop:, but that's another matter. (We initially
    used a "goto FINISH", but I hated that, too. You can use a "break" if
    you're in a loop.) We use a method that I really don't have time to
    describe now, but doesn't use a "goto". I hate goto's, but for the example
    above, it's efficient and much clearer than e.g. setting up a hash of op
    names and code to handle each op.

    7/12/05, Dave Ressler <<mailto:perl (AT) nettenna (DOT) com>perl (AT) nettenna (DOT) comwrote:
    >I have noticed a change in behavior in "goto" statements recently. Whereas
    >a statement like "goto PLACE;" would work fine no matter where "PLACE:"
    >was in my code, I've noticed that scripts that used to work are now
    >failing at the "goto" statement.
    >
    >I can probably work out an example if needed, but the general question is:
    >have any restrictions been put on "goto" recently? What are the real
    >criteria needed to be satisfied for the destination to be successfully found?
    >
    >Thanks,
    >Dave
    >
    >
    >Perl-Win32-Users mailing list
    ><mailto:Perl-Win32-Users (AT) listserv (DOT) ActiveState.com>Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    >
    >To unsubscribe:
    ><>
    >
    >
    >
    >
    >
    >Scanned for Spam and Viruses.
    >Content-Type: text/plain; charset="us-ascii"
    >MIME-Version: 1.0
    >Content-Transfer-Encoding: 7bit
    >Content-Disposition: inline
    >X-NAIMIME-Disclaimer: 1
    >X-NAIMIME-Modified: 1
    >
    >
    >Perl-Win32-Users mailing list
    >Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    >To unsubscribe:
    >
    >
    >Scanned for Spam and Viruses.


    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:
  • No.5 | | 246 bytes | |

    Wednesday 13 July 2005 13:30, Hugh Loebner wrote:
    Why on earth are you using a goto statement? They are pernicious.
    the contrary, a goto is often most appropriate in expressing clear program
    flow.
    Regards,
    Michael Erskine
  • No.6 | | 1387 bytes | |

    At 15:55 2005-07-13, John Deighan wrote:
    >but that's another matter. (We initially used a "goto FINISH", but I hated
    >that, too. You can use a "break" if you're in a loop.) We use a method
    >that I really don't have time to describe now, but doesn't use a "goto". I
    >hate goto's, but for the example above, it's efficient and much clearer
    >than e.g. setting up a hash of op names and code to handle each op.


    I think you just demonstrated why the dispatch table really is the way to
    go :)

    For instance, did you remember to wrap the goto in an eval to catch missing
    labels?

    It's not that goto is inherently bad, but it has a so very, very, very
    specific niche in modern languages with other program flow constructs. The
    only useful example I can think of is in C where you can use it to simplify
    resource allocation/deallocation. But in Perl no.

    Unless, of course, you're talking about goto LINE:
    http://search.cpan.org/~

    ;)

    /J

    -- -- -- - - - - -
    Johan L Sourcerer @ Boss Casinos johanl AT DarSerMan.com

    Latest bookmark: "TCP Connection Passing"
    http://tcpcp.sourceforge.net/
    dmoz: / 12

    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:
  • No.7 | | 389 bytes | |

    I doubt this.
    Please provide an example.

    HL

    7/13/05, Michael Erskine <michael.erskine (AT) ketech (DOT) comwrote:

    Wednesday 13 July 2005 13:30, Hugh Loebner wrote:
    Why on earth are you using a goto statement? They are pernicious.

    the contrary, a goto is often most appropriate in expressing clear
    program
    flow.

    Regards,
    Michael Erskine
  • No.8 | | 582 bytes | |

    My previous message was attached to the wrong posting.

    I doubt very much whether there is any occasion where gotos are "most
    appropriate." Please provide an example.

    Check ot "Go To Statement
    Considered Harmful" by Edsger W. Dijkstra

    7/13/05, Michael Erskine <michael.erskine (AT) ketech (DOT) comwrote:
    Wednesday 13 July 2005 13:30, Hugh Loebner wrote:
    Why on earth are you using a goto statement? They are pernicious.

    the contrary, a goto is often most appropriate in expressing clear program
    flow.

    Regards,
    Michael Erskine
  • No.9 | | 1303 bytes | |

    Hugh Loebner wrote:

    My previous message was attached to the wrong posting.

    I doubt very much whether there is any occasion where gotos are "most
    appropriate." Please provide an example.

    Check ot "Go To Statement
    Considered Harmful" by Edsger W. Dijkstra

    In structured programming practice, a goto would be totally inappropriate.

    But when you look at how a switch is implemented in actuality, it's
    full of goto's.

    I guess the point is that you should leave the gotos to the underlying
    generated compiler code and not use it yourself. But if your language
    is lacking on suitable constructs, you may be forced to use a goto just
    to save all the otherwise unnecessary code to go structured.

    My suggestion - avoid if possible - else use cautiously and infrequently.

    7/13/05, Michael Erskine <michael.erskine (AT) ketech (DOT) comwrote:

    >Wednesday 13 July 2005 13:30, Hugh Loebner wrote:
    >>

    Why on earth are you using a goto statement? They are pernicious.
    >>

    >the contrary, a goto is often most appropriate in expressing clear program
    >>flow.
  • No.10 | | 687 bytes | |

    Hugh Loebner wrote:
    My previous message was attached to the wrong posting.

    I doubt very much whether there is any occasion where gotos are "most
    appropriate." Please provide an example.

    Check ot "Go To Statement
    Considered Harmful" by Edsger W. Dijkstra

    of course, this has been discredited in the following discussion
    , for languages that do not have the
    equivalent of last/next type constructs for exiting loops in the middle
    of the loop (like C). it's a bit harder to find a justification while
    coding in perl. :)

    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:
  • No.11 | | 246 bytes | |

    Thursday 14 July 2005 03:26, Hugh Loebner wrote:
    My previous message was attached to the wrong posting.
    I doubt very much whether there is any occasion where gotos are "most
    appropriate." Please provide an example.
    TMTWTDI :)
  • No.12 | | 1790 bytes | |

    At 09:55 AM 7/14/2005, Lloyd Sartor wrote:
    >My opinion is that the goto statement can be useful in error handling
    >situations, particularly when parsing data. This removes the
    >rarely-executed error handling code from the expected, normal processing
    >code. This makes the normal code more cohesive, understandable, and
    >maintainable (IM) because it remains sequential, uncluttered by
    >unnecessary indentation, braces, etc. course, Perl provides synonyms
    >for 'goto' in these scenarios (last, continue).


    If you try it, you'll find that using eval {} and die() is much
    better for error handling. Especially since you can die() in
    arbitrarily nested subroutines. Even C (at least C++) has a similar
    behavior via the "try" construct.

    I think that it's absurd to claim that work done by Edsger W.
    Dijkstra, one of the most brilliant minds in Computer Science, has
    been discredited by someone with lesser credentials. The only case
    where I think that a 'goto' is justified is when no other alternative
    is available in the language you're using (usually a failing of the
    language) that is as computationally efficient, and computational
    efficiency is a major issue (it usually isn't). I've used it, but
    only in a very few cases.

    Personally (and I hope I'm not starting a spam war here), I feel the
    same way about last and continue, which usually indicate a
    not-too-well thought out loop condition. We have 101,396 lines of
    production code with 2 goto's, 0 continue's and 7 last's.

    Perl-Win32-Users mailing list
    Perl-Win32-Users (AT) listserv (DOT) ActiveState.com
    To unsubscribe:

Re: Change in "goto" behavior


max 4000 letters.
Your nickname that display:
In order to stop the spam: 1 + 0 =
QUESTION ON "Windows"

EMSDN.COM