Home > CFML, Web Development > Railo 1 – Adobe 0

Railo 1 – Adobe 0

I’ve decided to keep track of my investigation into Railo after being brainwashed enlightened at SotR09 (London).  I’ll post up about any issues I run into, comparisons and features that I think puts it above or below the level of Adobe’s CFML engine.

Named arguments in scoped functions

This has never worked in Adobe’s CFML and is something that I always thought would be useful.  Especially considering that the same style syntax works perfectly well for CFC’s.

<cffunction name="foo" returntype="string" output="false">
 <cfargument name="bar" type="string" required="true" />
 <cfreturn 'Yes' />
</cffunction>

<cfscript>
 st = StructNew();
 st.foo = variables.foo;
</cfscript>

<cftry>
 <cfoutput>foo (no scope): #foo(bar = 'bob')#</cfoutput>
 <cfcatch type="any">No</cfcatch>
</cftry>
<br />
<cftry>
 <cfoutput>variables.foo: #variables.foo(bar = 'bob')#</cfoutput>
 <cfcatch type="any">No</cfcatch>
</cftry>
<br />
<cftry>
 <cfoutput>st.foo: #st.foo(bar = 'bob')#</cfoutput>
 <cfcatch type="any">No</cfcatch>
</cftry>
<br />
<cftry>
 <cfoutput>variables.st.foo: #variables.st.foo(bar = 'bob')#</cfoutput>
 <cfcatch type="any">No</cfcatch>
</cftry>

ColdFusion 7 + 8

foo (no scope): Yes
variables.foo: No
st.foo: No
variables.st.foo: No

Railo 3.1

foo (no scope): Yes
variables.foo: Yes
st.foo: Yes
variables.st.foo: Yes

Conclusion

I’ve filed this as a bug with Adobe and possibly even with Macromedia and they never acted on it.  But Railo have gone along with common sense and made sure it was possible from the start.  Support this syntax would allow you to, for example, store your own functions in the application scope and still retain the benefits of named arguments like optional ones.

Thanks Railo.

Categories: CFML, Web Development
  1. June 17, 2009 at 10:39 pm | #1

    Nice one! Good to know.
    Now if they would also support javascript-like anonymous functions as in [cfreturn functionNew(){..} /], it would even more rock & Railo!

  1. No trackbacks yet.