TypeSpecification-class(TypeInfo)
TypeSpecification-class()所属R语言包:TypeInfo
Class "TypeSpecification" and derived class
类的“TypeSpecification”和派生类
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The classes in this collection are used to represent type information about a function in different ways. TypeSpecification is the virtual base class and provides the common slot to describe the type for the return value of the function.
在此集合类,用来代表不同的方式的函数的类型信息。 TypeSpecification是虚拟基类,并提供了常见的插槽来描述函数的返回值的类型。
The ReturnTypeSpecification-class is used when there is no information about the parameters of the function (either because there are no parameters or because we have no constraints on them).
有没有关于函数的参数的信息(无论是因为没有参数,或者是因为我们对他们没有约束)时使用ReturnTypeSpecification-class。
The classes IndependentTypeSpecification-class and SimultaneousTypeSpecification-class are used to describe constraints on the arguments to the function. Both are lists, but behave very differently in the type checking. The difference is more difficult to describe succinctly than it is conceptually.
类IndependentTypeSpecification-class和SimultaneousTypeSpecification-class是用来描述函数的参数的约束。都是列表,但表现非常不同的类型检查。不同的是更困难的简洁来形容,比它是概念。
SimultaneousTypeSpecification-class is used when we want to specify information about the types of several arguments in a call taken as a group and imposing a constraint on that group of values. This corresponds to a call signature in the method dispatching. It says match each argument in turn with the given types and confirm the match over all of these tests. For example, we might have a function that accepts either (a) two numbers, or (b) two matrices. In that case, we need to specify the acceptable argument types as pairs: c("numeric", "numeric") and c("matrix", "matrix"). The key idea here is that the constraints on the types are AND-ed together across the different arguments. In our example, we impose the constraint is.numeric(arg1) && is.numeric(arg2).
SimultaneousTypeSpecification-class使用时,我们要指定几个参数作为一个群体采取了呼叫类型的信息,并征收该组的值约束。这相当于在调度方法的调用签名。它说,在给定的类型之交相互匹配的论点,并确认了所有这些测试的比赛。例如,我们可能有一个函数,接受或者(a)两个数字,或(b)两个矩阵。在这种情况下,我们需要对指定为接受的参数类型:C(“数字”,“数字”)和c(“矩阵”,“矩阵”)。这里的关键思想是类型的限制,以及男女在不同的参数。在我们的例子中,我们施加的约束is.numeric(arg1) && is.numeric(arg2)。
The IndependentTypeSpecification-class is used when we want to specify something about the types of different parameters but do not want the types to be AND-ed together. If we had a function that accepts a matrix or a number for its first parameter, and a matrix or string for its second parameter or any combination of those, then we would use the IndependentTypeSpecification-class. The term 'independent' is intended to suggest that the type checking is done for each parameter separately or independently of the others and then the check succeeds if all arguments pass. The phrase simultaneous means that we test the types of the arguments as a unit or simultaneously. The names can be easily changed to something more suggestive. It is the concept that is important.
IndependentTypeSpecification-class使用时,我们要指定不同的参数类型的东西,但不想要的类型和男女一起。如果我们有一个函数,接受其第一个参数矩阵或数字,其第二个参数或任何组合的矩阵或字符串,然后我们将使用IndependentTypeSpecification-class。术语“独立”的目的是表明,类型检查的其他参数为每个单独或独立完成,然后检查成功,如果所有的参数传递。这句话同时意味着,我们作为一个单位或同时参数测试的类型。名称可以很容易地改变的东西更多的暗示。它的概念,这一点很重要。
A description of a quite different nature may also help and also provide information about the contents of these different list classes. For IndependentTypeSpecification-class, one can think of the list as having an element for each parameter for which we want to specify type information. This element is, at its simplest, a character vector giving the names of the acceptable classes. (We can have more complex elements such as expressions.) I think of this as being a collection of column vectors hanging from the parameters.
一个完全不同的性质的描述,也可以帮助,并提供有关这些不同的列表类的内容的信息。 IndependentTypeSpecification-class,可以认为列表,每个参数的元素,我们要指定类型信息。此元素是,在其最简单的给予可接受的类的名称,特征向量。 (我们可以有更复杂的元素,如表达。)我觉得这是一列挂从参数向量的集合。
For SimultaneousTypeSpecification-class, we have rows or tuples of type information. These are call signatures. So we have
SimultaneousTypeSpecification-class,我们的行或元组类型的信息。这些都是调用签名。因此,我们必须
IndependentTypeSpecification corresponds to the SimultaneousTypeSpecification in the following computational manner. We can take the cartesian product (e.g. via expand.grid) of the inputs for IndependentTypeSpecification to form all possible combinations of types for the parameters and then we have the tuples for the corresponding SimultaneousTypeSpecification.
IndependentTypeSpecification对应SimultaneousTypeSpecification在下面的计算方式。我们可以采取的笛卡尔乘积(例如,通过expand.grid)为输入IndependentTypeSpecification形成的参数的类型所有可能的组合,然后我们有相应的SimultaneousTypeSpecification元组。
构造----------Constructors----------
One can create objects of the three non-virtual classes using the corresponding constructor functions in the package. These are ReturnTypeSpecification, IndependentTypeSpecification, SimultaneousTypeSpecification.
可以创建三个非虚包中使用相应的构造函数的类的对象。这些都是ReturnTypeSpecificationIndependentTypeSpecification,SimultaneousTypeSpecification。
插槽----------Slots----------
.Data: each of the non-virtual classes is really a list. They inherit the list properties and all the relevant
.Data:每个非虚类,确实是一个列表。他们继承列表属性和所有有关
returnType: Object of class ClassNameOrExpression-class. This describes the return type for the function. In SimultaneousTypeDescription objects, we can also specify return type information corresponding to each signature, i.e. in the TypedSignature-class.
returnType类ClassNameOrExpression-class的对象。这说明该函数的返回类型。在SimultaneousTypeDescription对象,我们也可以指定返回类型的信息对应到每一个签名,即TypedSignature-class。
延伸----------Extends----------
Class "list", from data part. Class "TypeSpecification", directly. Class "vector", by class "list".
类"list",从数据的一部分。类"TypeSpecification",直接。类"vector"类"list"。
方法----------Methods----------
Available methods are computed in the example below; see the corresponding help page for details.
在下面的例子可用的方法计算;有关详细信息,请参阅相应的帮助页面。
作者(S)----------Author(s)----------
Duncan Temple Lang <duncan@wald.ucdavis.edu>
参见----------See Also----------
IndependentTypeSpecification SimultaneousTypeSpecification ReturnTypeSpecification typeInfo, typeInfo<- checkArgs, checkReturnValue
IndependentTypeSpecificationSimultaneousTypeSpecificationReturnTypeSpecificationtypeInfo,typeInfo<-checkArgs,checkReturnValue
举例----------Examples----------
showMethods(classes=c(
"TypeSpecification",
"IndependentTypeSpecification",
"SimultaneousTypeSpecification",
"ReturnTypeSpecification"))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|