in reply to A matter of style
Purists say there should only be one entry and one exit and anything else is obfu. What do you say?
One entry to a subroutine yes. One exit no. Many people have disagreed with this point and for good reason. It increase code clutter, it increases code complexity, and often increases code duplication. About the only really useful argument that I can think of for only having one exit to a routine is to be able to positively determine the returned value. But theres lots of ways around that without losing clarity.
sub one_exit { my $foo=shift; my $return=shift; CORE:{ last CORE unless $foo; #... last CORE if $foo eq "bar"; #... } return $return }
or even easier is to just rename the sub for a bit and create a wrapper that calls it, allowing you to intercept its entry and exit, without artificial constraints confusing your code.
---
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A matter of style
by pfaut (Priest) on Feb 14, 2003 at 23:11 UTC | |
by Abigail-II (Bishop) on Feb 14, 2003 at 23:37 UTC | |
by demerphq (Chancellor) on Feb 15, 2003 at 10:30 UTC |