good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Re: Double your return!!!!by pfaut (Priest) |
on Feb 19, 2003 at 15:01 UTC ( [id://236655]=note: print w/replies, xml ) | Need Help?? |
A called routine should not make any assumptions about the routine that called it, or the routine that called that routine, etc. As stated in the base node, if you really want to do this, the proper way would be some kind of exception signalling mechanism. Here's your little snippet.
Now, I doubt very much that the whole point of this subroutine was to ask for a couple of pieces of information and throw them away. So, there would probably be some code after the second return that actually does something with $foo and $baz. Suppose there were a couple of other places in your program that needed to ask for these pieces of information. Instead of having those four lines all over your code, you decide to refactor and make a separate subroutine called getFooAndBaz() to ask for those values. Does askFor() now have to jump three call frames? Why should it care what path was taken to call it? How does that affect the procedure that calls askFor() directly?
In Section
Seekers of Perl Wisdom
|
|