Search code examples
coldfusionclosurescoldfusion-10

A Closure Cannot Call Any User-Defined Function in CF 10? why?


Note: A closure cannot call any user-defined function, because the function's context is not retained, though the closure's context is retained. It gives erroneous results. For example, when a closure is cached, it can be properly called for later use, while a function cannot.

Quoted from: http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSe61e35da8d31851842acbba1353e848b35-7ffa.html

Would someone please elaborate on this? Why can't closure call UDF's?

Can closure can call CF built-in functions? or just User-Defined functions?

I think understanding the limitation of this is crucial. Thank you.


Solution

  • A closure can call both CF built-in functions and User-Defined functions. There is no limitation whatsoever with CF's implementation and you can try yourself to verify the same.

    The doc note present is because of a bug logged (with prerelease) that a cached closure instance (say in application scope) was not able to cal UDFs when executed twice. I believe it was fixed and hence the note should be removed.

    p.s. I worked on closure's implementation in ColdFusion