IndependentTypeSpecification(TypeInfo)
IndependentTypeSpecification()所属R语言包:TypeInfo
Create separate type information for different parameters.
创建不同参数的类型信息。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function is a constructor for the IndependentTypeSpecification-class class. In short, it collects information about the possible types of parameters that is used to validate arguments in a call separately. This contrasts with checking the combination of arguments in the call against a particular signature.
此功能是为IndependentTypeSpecification-class类的构造函数。总之,它收集有关参数分别用来验证调用中的参数可能的类型的信息。这对比检查参数相结合,在对某一特定签名的呼叫。
用法----------Usage----------
IndependentTypeSpecification(..., returnType, obj = new("IndependentTypeSpecification", list(...)))
参数----------Arguments----------
参数:...
name elements of which are either character vectors or expressions/calls that can be evaluated. These are of type ClassNameOrExpression-class.
其中的名称元素是字符向量或表达式/检测可评估。这些类型ClassNameOrExpression-class。
参数:returnType
the expected type of the return value. This is optional.
预期的返回值类型。这是可选的。
参数:obj
the instance of class TypeSpecification-class that is to be populated with the values from ... and returnType.
TypeSpecification-class类的实例是从...和returnType值填充。
值----------Value----------
The return value is obj after it has been populated with the arguments ... and returnType.
返回值是obj后,它已被与参数...和returnType填充。
作者(S)----------Author(s)----------
Duncan Temple Lang <duncan@wald.ucdavis.edu>
参见----------See Also----------
typeInfo, typeInfo<- checkArgs, checkReturnValue IndependentTypeSpecification-class SimultaneousTypeSpecification SimultaneousTypeSpecification-class
typeInfo,typeInfo<-checkArgs,checkReturnValueIndependentTypeSpecification-classSimultaneousTypeSpecificationSimultaneousTypeSpecification-class
举例----------Examples----------
pow = function(a, b)
{
# the return here is important to ensure the return value is checked.[重要的是要确保检查返回值返回这里。]
return(a^b)
}
typeInfo(pow) =
IndependentTypeSpecification(
a = c("numeric", "matrix", "array"),
b = "numeric",
returnType = quote(class(a))
)
IndependentTypeSpecification(
a = c("numeric", "matrix", "array"),
b = new("StrictIsTypeTest","numeric"),
c = new("StrictIsTypeTest",c("numeric", "complex")),
d = as("numeric", "NamedTypeTest"),
e = new("InheritsTypeTest", c("numeric", "complex"))
)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|