--- Kurt Edmiston <[EMAIL PROTECTED]> wrote:
> Here's a topic for discussion:

And a good one. =o)
 
> Coming from C++-land, I've always been taught over and over again
> that all subroutines/functions/blocks/etc should have only a single
> entry point and a single exit point.  "It's just good programming
> practice."

I've heard the same thing, and understand the philosophy -- but it's a
philosophy. C wasn't written for philosophers, really; it's geared for
gearheads and engineers. Perl is geared for users -- i.e., whoever
happens to be using it. It's *great* for us gearheads, because we can
play sick and twisted cryptocontextual games, but it's also good for us
philosophers, who think about the aesthetics of the code in terms of
creativity and elegance as well as readability and efficiency. (You may
throw things at the purple prose now. ;o)

> But now in the world of Perl, I've observed that a "Perl-ish" thing
> to do is to place multiple return/exit/etc statements in certain
> blocks of code or in conditional blocks. 
> (Then again, maybe it isn't Perl-ish, but I've had to sort through
> many perl scripts like this.)

Seems pretty Perl-ish to me. =o)
tmtowtdi.
 
> I guess I'm just curious to know what other more experienced Perl 
> programmers think about this.  I still adhere strictly to the "one
> way in, one way out" philosophy, mainly for the sake of readability.

Do what makes sense to you -- but is it really always more readable?
Will the maintainers who come behind you be able to quickly understand
why you're setting variables instead of exiting the routine once you
already know that there's nothing else to do here? Will they realize
there's nothing else to do, or must you add a few lines of comments to
clarify? Not that commants are a *bad* thing, of course, lol...

> But I understand how much easier it can make a programmer's task to
> write something like "if (some condition) { exit; }"

Easier, and pretty clear and readable, I'd say, even *without*
comments.

> Also, I was wondering if exiting prematurely like this from a program
> has any adverse affects on the execution of the program.

Nah. Perl cleans up all the loose ends (unless you've done something
*REALLY* nasty, lol!!)



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to