Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

RE: Number of times I've used goto in Perl

by Simplicus (Monk)
on Apr 19, 2000 at 18:51 UTC ( [id://8035]=note: print w/replies, xml ) Need Help??


in reply to Number of times I've used goto in Perl

I only used goto once in my life (explicitly)(I'm not counting uses of goto made by others in packages or modules I have included. I'm not a snob, I've just never found it useful. A language construct should clarify, not obfuscate, and goto almost always "spaghettifies" the code.
If someone can come up with an example of an instance where goto is necessary for the purpose of clarification in code, I'd love to see it.

Simplicus
  • Comment on RE: Number of times I've used goto in Perl

Replies are listed 'Best First'.
RE: RE: Number of times I've used goto in Perl
by buzzcutbuddha (Chaplain) on Apr 19, 2000 at 22:20 UTC
    I have never used GOTO in Perl, but in Visual Basic, which I learned in school. There
    it's used for error handling where you would say:
    On Error Goto ErrHandler
    and then construct an appropriate subroutine underneath the ErrHandler tag to handle the error.
    I believe the reason that VB uses GOTO in that situation is because an error can
    conceivably occur at anypoint, and you want to be able to catch it immediately, instead
    of wrapping things in a TRY..EXCEPT model. But that type of unexpected error seems to me
    more of a problem in an 'event driven' piece of code, and not so much the style with which
    Perl is used. Plus I think that it is more difficult to use than other methods I have seen.
    So I personally cannot see the value of GOTO in Perl, though I do not deny it's validity, or the
    skills of anyone who uses it.
    just my $0.02..
Re^2: Number of times I've used goto in Perl
by JavaFan (Canon) on Jun 08, 2010 at 12:47 UTC
    If someone can come up with an example of an instance where goto is necessary for the purpose of clarification in code, I'd love to see it.
    necessary? I doubt many examples exists. However, I doubt there are many examples showing OO to be necessary for the purpose of clarification (or any other purpose). Necessary implies there not being an alternative. In Perl, there's almost always an alternative. Whether it's for goto, or OO.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://8035]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found