Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl style question: loops with postcondition

by Stegalex (Chaplain)
on Jun 28, 2002 at 14:33 UTC ( [id://178018]=note: print w/replies, xml ) Need Help??


in reply to Perl style question: loops with postcondition

Serious question:
Is there a legitimate need for goto? If not, shouldn't this language construct be deprecated?

P.S. No offense to fans of the venerable 'goto'.

~~~~~~~~~~~~~~~
I like chicken.
  • Comment on Re: Perl style question: loops with postcondition

Replies are listed 'Best First'.
Re: Re: Perl style question: loops with postcondition
by erikharrison (Deacon) on Jun 28, 2002 at 16:11 UTC

    YES! Mostly, we have goto LABEL and goto EXPR for the sake of completeness. People expect them to be there, and there they are. This is useful.

    But much more importantly, goto can be used to eliminate / substitute one subroutine call for another. For example, suppose you have a subroutine which uses caller. Now, what if that sub is called by and AUTOLOAD in the same package. You've borked your caller. But, if you goto to the subroutine, then even caller can't figure out that AUTOLOAD itercepted the call.

    Cheers,
    Erik

    Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet

Re: Re: Perl style question: loops with postcondition
by fruiture (Curate) on Jun 28, 2002 at 16:25 UTC
    I think that's like "The -w switch is not mandatory." If you know, what you do, it can be (in a very strange and unimaginable situation) usefull to have goto.
      "unimaginable situation" is of course nonsense, as erik wrote about AUTOLOAD i remembered even i had used goto &$subref for nested AUTOLOAD routines in a module that exports an AUTOLOAD routine to the use()ing package but gives a possibility to specify a sub-reference that handles function that could not be found by the current AUTOLOAD routine.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found