Skip to main content
Participant
June 5, 2008
Question

Does CFFUNCTION Outside of a Component Create an Object?

  • June 5, 2008
  • 1 reply
  • 327 views
I created a user-defined function using the cffunction tag, but this function is NOT wrapped within a component (cfcomponent tag); rather, it's created just like functions that are written using cfscript; it's just that my particular function uses the cffunction tag instead of cfscript. I then call the function just like I would call a function written using cfscript: #myFunction(someArgument)#. I would like to know whether this approach will create an object when the function is called. My guess is a resounding no, since this seems to be just a plan old function, and no CFCs are involved. Thanks!
This topic has been closed for replies.

1 reply

Inspiring
June 5, 2008
> I would like to know whether this approach will
> create an object when the function is called. My guess is a resounding no,
> since this seems to be just a plan old function, and no CFCs are involved.

Your instincts are correct.

Ask yourself this: what type of object would it be if it *was* to create an
object? Could there be a type of object that would be sensible to create
in this case? No, I don't think so.

A function is a function, it doesn't matter if the syntax used is CFML or
CFScript. <cffunction> offers slightly more functionality - the additional
attributes one can supply - but other than that, they're the same.

As you allude to, it's the CFC that gets created as an object - via
<cfinvoke>, <cfobject> or createObject() - not the functions within it.

Make sense?

Out of interest... what prompted the question?

--
Adam