Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl style question: loops with postcondition

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 12: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 12: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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.