views:

250

answers:

3

Can function argument have hint in cfscript (CF9)?

CFML style:

<cffunction name="myFunc" output="false" returntype="void">
  <cfargument name="arg1" type="arg1" default="default" hint="my hint">
  ...
</cffunction>

CF9 cfscript style:

public void function myFunc(string arg1='default') {
  ...
}

Where to specify hint of the argument (arg1) above?

+12  A: 

The easiest way is to to use JavaDoc notation.

component{

/**
* @hint This is a hint
* @arg1 This is an argument hint
* @arg2 This is another argument hint 
*/
public void function myFunc(string arg1='default', numeric arg2) {
  return TRUE;
}

}

Terry Ryan
This method only attaches the hint to the function, but not to the argument 'arg1'.
Henry
I have altered it to show the right syntax. Sorry about that.
Terry Ryan
oh I see! Thank you! I can't find this from the documentation.
Henry
+2  A: 

I've not played with cf9, but you can do something like this in CF8:

<cffunction name="myFunc" output="false" returntype="void">
  <cfargument name="arg1" type="arg1" default="default" hint="my hint">
  <cfscript>
    //do stuff
  </cfscript>
</cffunction>

Not ideal, but maybe an acceptable comprimise.

Ben Doom
A: 

While Terry's answer is completely correct and valid, I'm personally not a fan of using that @ JavaDoc notation (one per line) above functions due to the number of lines it eats up. I prefer doing it inline like this:

public void function myFunc(string arg1='default', numeric arg2) hint="This function does something" {
  return TRUE;
}

Either way does the same thing, it's just a coding-style preference.

mujimu
the question asked how to specify hint for arguments
Henry