Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Would you use 'goto' here?

by demerphq (Chancellor)
on Dec 06, 2001 at 15:51 UTC ( #129888=note: print w/ replies, xml ) Need Help??


in reply to Would you use 'goto' here?

Considering that one of your objectives is to control what caller() reports then I think that using goto &sub is prefectly legitimate, after all that was the very reason why it is included in the language at all.

However to address the readability/maintainability of your code I think that perhaps you are taking the wrong approach, a slight change in methodology would IMO make it much more clear. Instead of having one sub that handles both the forwarding and the processing of one case, use one sub that forwards to two others. Give it a nice convienient, obvious name and presto, you get the magic with the readability:

sub edit_product_disptacher { # uses magic goto to fool caller() my ($query)=@_; if ( $query->param( 'officeID' ) ) { goto &edit_office_product } else { goto &edit_product } }
It seems to me that documenting that you are using a magic goto and why should be sufficient for and support programmer. It tells them what you are doing (so they can easily find the docmentation) and why, and once they read the docs they will (er, should :-) understand perfectly whats going on.

Yves / DeMerphq
--
This space for rent.


Comment on Re: Would you use 'goto' here?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-12-25 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls