My Secret Life as a Spaghetti Coder
home | about | contact | privacy statement
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!


Comments
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 - 5 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 - 5 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 - 5 hrs

I also meant to say, looks like Tim (Farrar) was right...

Posted by Sam on Jun 21, 2007 at 12:37 PM UTC - 5 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 - 5 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 - 5 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 - 5 hrs

Leave a comment

Leave this field empty
Your Name
Email (not displayed, more info?)
Website

Comment:

Subcribe to this comment thread
Remember my details
Google
Web CodeOdor.com

Me
Picture of me

Topics
.NET (19)
AI/Machine Learning (14)
Answers To 100 Interview Questions (10)
Bioinformatics (2)
Business (1)
C and Cplusplus (6)
cfrails (22)
ColdFusion (78)
Customer Relations (15)
Databases (3)
DRY (18)
DSLs (11)
Future Tech (5)
Games (5)
Groovy/Grails (8)
Hardware (1)
IDEs (9)
Java (38)
JavaScript (4)
Linux (2)
Lisp (1)
Mac OS (4)
Management (15)
MediaServerX (1)
Miscellany (76)
OOAD (37)
Productivity (11)
Programming (168)
Programming Quotables (9)
Rails (31)
Ruby (67)
Save Your Job (58)
scriptaGulous (4)
Software Development Process (23)
TDD (41)
TDDing xorblog (6)
Tools (5)
Web Development (8)
Windows (1)
With (1)
YAGNI (10)

Resources
Agile Manifesto & Principles
Principles Of OOD
ColdFusion
CFUnit
Ruby
Ruby on Rails
JUnit



RSS 2.0: Full Post | Short Blurb
Subscribe by email:

Delivered by FeedBurner