I was teaching Advanced ColdFusion last week; it was the first time I have taught that course in its CF8 variation. I tend to spend a great deal of time debugging errors in student code, most of which is derived from trivial typing mistakes; but this this time I got a stumper.
One of my students, in a fit of copy/paste ecstasy, copied the entire body entire function (omitting the <cffunction> and <cfargument> tags, and then proceded to delete the parts he didn't like. When he finished, the resulting code displayed no output.
Further investigation revealed that there was a <cfreturn /> statement lurking in the middle of the code--but it was not in a function. Strangely, enough, it did not throw an error. It simply "returned", whatever that means in this context. Perhaps cf8 runs pages in the context of an implicit onRequest() function (see Application.cfc), even if one is not defined? I also tested this w/an Application.cfm, confirming that it behaves identically under that circumstance as well.
Code looked something like this:
<cfset a = 1 />
<cfreturn />
<cfoutput> #a# </cfoutput>
I am open to alterntive suggestions....
Nov 4, 2009 at 1:52 AM this is nice information need to know more