TypeInfo (version 1.38.0)

IndependentTypeSpecification: Create separate type information for different parameters.

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

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.

See Also

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

Examples

Run this code
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"))
 )

Run the code above in your browser using DataLab