I've also been taught that it's bad style to have multiple exit points from
a function. That said, I do it all the time. Frequently, if I want to exit
with an error (when the return value is an error code) I'll exit the
function without trying to do any more processing.
I'll also use multiple exit points in similar cases (to give a more general
example) where you do some processing, and if a conditional is true, then
you return A, else do more processing, and see if you return B, else do more
processing....
This can reduce the number of local variables, the number of comparisons
that must be done, and (most importantly) it can reduce code complexity.
-- Ben Doom
Programmer & General Lackey
Moonbow Software, Inc
: -----Original Message-----
: From: DURETTE, STEVEN J (AIT) [mailto:[EMAIL PROTECTED]
: Sent: Monday, July 28, 2003 2:55 PM
: To: CF-Talk
: Subject: RE: CFRETURN has incorrect documentation
:
:
: Raymond,
:
: I use the method that you list below that "doesn't make sense to me."
:
: This is a hold over (for me anyway) of my early programming days.
: [Remember
: when BASIC (not visual) was the learning language of choice! ;) ]
:
: I was always taught that it was poor programming to break out of code and
: leave it hanging. That's the same reason (in my opinion) that many
: programmers hated GOTO.
:
: Steve
:
:
: -----Original Message-----
: From: Raymond Camden [mailto:[EMAIL PROTECTED]
: Sent: Monday, July 28, 2003 2:21 PM
: To: CF-Talk
: Subject: RE: CFRETURN has incorrect documentation
:
:
: I think the docs meant to say you should not do this:
:
: <cfreturn 1>
: <cfreturn 2>
:
: This will return 1. The only reason to not do this is because it's a
: waste of time. As soon as the first cfreturn is encountered, the method
: ends.
:
: However, the code I sent in my other message would make sense... in one
: condition return A, in another condition return B.
:
: Some people will do...
:
: <cfset returnCode = "a">
: <cfif condition>
: <cfset returnCode = "b">
: </cfif>
:
: <cfreturn returnCode>
:
: But that just doesn't make sense to me.
:
: ========================================================================
: ===
: Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
: (www.mindseye.com)
: Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)
:
: Email : [EMAIL PROTECTED]
: Blog : www.camdenfamily.com/morpheus/blog
: Yahoo IM : morpheus
:
: "My ally is the Force, and a powerful ally it is." - Yoda
:
: > -----Original Message-----
: > From: jon hall [mailto:[EMAIL PROTECTED]
: > Sent: Monday, July 28, 2003 12:15 PM
: > To: CF-Talk
: > Subject: Re: CFRETURN has incorrect documentation
: >
: >
: > multiple cfreturn's? Does it just return the second value or what?
: >
: > --
: > jon
: > mailto:[EMAIL PROTECTED]
: >
: > Monday, July 28, 2003, 2:05:12 PM, you wrote:
: > BH> CFRETURN's documentation says that a maximum of one CFRETURN is
: > BH> allowed per function. But I have code that does multiple
: > CFRETURNs
: > BH> and it works just fine. Let's not argue whether that's a good
: > BH> programming practice, but do you think Macromedia will
: > ever change
: > BH> ColdFusion to disallow multiple CFRETURNs so that it
: > agrees with the
: > BH> documentation?
: >
: > BH>
: >
:
:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at
http://www.coolfusion.com
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4