in reply to Re^23: Why is the execution order of subexpressions undefined?
in thread Why is the execution order of subexpressions undefined?

Hey. If goto is bad, why is it in the language?

It is rarely used, but it is there for those occasions when it is necessary, or easier or clearer.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

Replies are listed 'Best First'.
Re^25: ???
by Anonymous Monk on Apr 15, 2005 at 14:45 UTC
    Hey. If EOD is bad, why is it in the language?

    It is rarely used, but it is there for those occasions when it is necessary, or easier or clearer.

Re^25: Why is the execution order of subexpressions undefined?
by tilly (Archbishop) on Apr 22, 2005 at 20:24 UTC
    The reason that the traditional goto is in Perl is that it makes it easier to port programs to Perl. See the a2ps2p utility. The lack of labelled loop control makes goto useful far more often in C, but in Perl you can always rewrite a given piece of code to not use goto and yet run identically algorithmically. (Knuth wrote a famous paper about this in the 70s.)

    Of course there is always the unexpected. I have seen exactly one (Switch) use of goto in Perl that I would consider justifiable.

      tilly,
      Have you changed your mind or lost it? At least twice in the past, you have said there are 2 neccessary uses of traditional goto in Perl. Even if you didn't mean necessary, you still said two.

      Cheers - L~R

      For anyone who doesn't have a sense of humor, suggesting that tilly might have lost his mind is a joke
        My mind has not changed, and I have not lost it. I have seen 2 good reasons to use the traditional goto in Perl, and I describe both above.

        One was in Switch. The other is in the output of an automatic translator. (I originally said the wrong one, it is s2p that spit out lots of gotos, because sed code has lots of gotos in it.) I believe that the other was the original reason to have goto in Perl - Larry Wall wanted to convince people that they could learn Perl and do what they did with awk and sed, plus more, with just one tool. The automatic translation utilities made this feasible. But they would have been hard to write if you weren't allowed translate goto to goto.