如何在CFscript中指定参数属性?(CF9)

Hen*_*nry 3 coldfusion

在CF9 doc中:在CFScript中定义组件和函数,它说:

/** 
*Comment text, treated as a hint. 
*Set metadata, including, optionally, attributes, in the last entries 
*in the comment block, as follows: 
*@metadataName metadataValue 
... 
*/ 
access returnType function functionName(arg1Type arg1Name="defaultValue1" 
arg1Attribute="attributeValue...,arg2Type 
arg2Name="defaultValue2" arg2Attribute="attributeValue...,...) 
functionAttributeName="attributeValue" ... { 
body contents 
}
Run Code Online (Sandbox Code Playgroud)

你怎么说arg1Attribute?我试过这个:

public void function setFirstname(string firstname="" displayName="first name"){}
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

另外,你如何将其翻译成脚本风格?

<cffunction name="setPerson">
  <cfargument name="person" type="com.Person"/>
</cffunction>
Run Code Online (Sandbox Code Playgroud)

我试过了:

function setPerson(com.Person person){}
Run Code Online (Sandbox Code Playgroud)

它也不起作用."在这种情况下,你不能在"."运算符中使用变量引用"它说.

Ray*_*den 6

事实证明这是一个文档错误.无法为脚本块中的参数提供元数据.您可以执行提示,必需,类型和默认值,但不能执行任何其他操作.我在询问com.Person的事情.Mark Mandel建议导入com并使用Person.