Viewing By Entry / Main
October 9, 2006
Some minor updates to the Closures for CFMX library:
  • You can now make a closure from a text expression - if the factory doesn't find return and ; in the code block it will add them automatically.
  • The call() method is automatically an alias for the generated function which means that if you provide an argument specification, you no longer have to use named arguments in the method call.
  • The code examples have been updated to better illustrate the equivalent of the Ruby select / filter example on Fowler's bliki (link posted by Peter Bell on the previous entry)
I'll try to get the code posted to Google Code but may well reorganize my Concurrency project at the same time to create a single project for all future corfield.org open source libraries.

Comments

VERY COOL!! I have just 1 suggestion: make the physical path to the directory where the closure files get written a configuration value so it's easy to have closures "just work" from any level of your file hierarchy.

I modified your ClosureFactor.cfc file as shown below to do this and it's working.

<cfset variables.baseFilePath = "" /><!--- Base file path to org/corfield/closure directory NO TRAILING SLASH --->

<cffunction name="init" returntype="org.corfield.closure.ClosureFactory" > <cfargument name="baseFilePath" type="string" required="true" >

<cfset variables.baseFilePath = arguments.baseFilePath >

<cfreturn this > </cffunction>

(in makeClosureFromString) ..... <!--- synthesize a unique function name: ---> <cfset functionName = "_" & replace(createUUID(),"-","","all") /> <cfset filePath = variables.baseFilePath & "/" & functionName /> <!--- if the code seems to be script code, wrap it in a cfscript tag: ---> ......

and of course the fall to the ClosureFactory becomes:

<cfset cf = createObject("component", "org.corfield.closure.ClosureFactory").init( "<<< physical path to /org/corfield/closure >>>" ) >


I've logged this in the issue tracker (more details shortly as I bring the combined project online).


Post Your Comments
Name:
Email Address:
Comments
*** Please note that all comments require moderation so it may be some time before your comment posts to this blog! ***
Remember My Information:
 



Hosting provided by