I
thought I had read this somewhere, about not being able to use "
cf
" as a prefix to a function, but when I defined all those functions in scriptaGulous with that prefix, and it let me, I thought maybe I made the whole thing up.
But then today I was having a look through the
docs for cfscript
, and I found this:
Caution: ... You cannot put a user-defined function whose name begins with any of these strings within this tag:
-
cf
-
cf_
-
_cf
-
coldfusion
-
coldfusion_
-
_coldfusion
However, so far it has let me with no problems. What shall be done?
Hey! Why don't you make your life easier and subscribe to the full post
or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate
wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!
Leave a comment
I was thinking... maybe that just means I can't define a function in cfscript that begins with any of those strings.
I ran a test, and sure enough it didn't work. When I tried to call any method on it, it told me the object that held the method wasn't defined.
Posted by
Sam
on Jun 21, 2007 at 12:27 PM UTC - 6 hrs
Doh... maybe not. When I try it outside of a component, like this:
function cfstupendous()
{
return 1;
}
writeoutput(cfstupendous());
I get no problems...
Posted by
Sam
on Jun 21, 2007 at 12:29 PM UTC - 6 hrs
So, the problem I was encountering before was I forgot to "return this;" at the end of my init method.
Oh boy, today is looking like my brain is a bit off!
So, what shall be done?
Posted by
Sam
on Jun 21, 2007 at 12:31 PM UTC - 6 hrs
I also meant to say, looks like Tim (Farrar) was right...
Posted by
Sam
on Jun 21, 2007 at 12:37 PM UTC - 6 hrs
I might be a bit confused - is a cf prefix allowed inside CFCs but not outside of them?
Posted by
Peter Boughton
on Jun 26, 2007 at 07:42 AM UTC - 6 hrs
My confusion comes from the fact that indeed, I can use a function prefixed with CF anywhere I try (so scriptaGulous works), but the docs say that it shouldn't work.
The consensus in the few comments at
http://www.codeodor.com/index.cfm/2007/6/7/What-ar...seems to indicate that no one (including at least one person on the CF team - to my knowledge) rates the possibility of these becoming reserved functions.
So, the question now becomes, are they planning to ever fix this "bug," or allow us to use functions with cf as a prefix? (not sure why they'd care much anyway what we named our function as long as it wasn't a reserved word).
As always, insight and advice are much appreciated!
Posted by
Sam
on Jun 26, 2007 at 08:27 AM UTC - 6 hrs
Oh, and Peter - to answer your question, the cf prefix on a function works fine everywhere. The docs do not match the behavior, at least in CFMX 7.
Posted by
Sam
on Jun 26, 2007 at 08:28 AM UTC - 6 hrs
Leave a comment