Question

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.

Était-ce utile?

La 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

Autres conseils

A closure retains a copy of variables visible at the time of its creation.

This is basically the definition of a closure in computer science. A captured environment and some code to evaluate in that context.

The restrictions on calling functions from closures appears to be a bug in the implementation of closures in ColdFusion -- functions being unable to access their environment, from the environment captured by the closure.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top