IndependentTypeSpecification: Create separate type information for different parameters.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/Classes.S

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.

Usage

1
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.

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.

Value

The return value is obj after it has been populated with the arguments ... and returnType.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

See Also

typeInfo, typeInfo<- checkArgs, checkReturnValue IndependentTypeSpecification-class SimultaneousTypeSpecification SimultaneousTypeSpecification-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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"))
 )

TypeInfo documentation built on Nov. 8, 2020, 5:40 p.m.