SimultaneousTypeSpecification: Create type signature information governing parameters in a...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/Classes.S

Description

This function is a constructor for specifying different permissible combinations of argument types in a call to a function. Each combination of types identifies a signature and in a call, the types of the arguments are compared with these types. If all are compatible with the specification, then the call is valid. Otherwise, we check other permissible combinations.

Note that if an instance of SimultaneousTypeSpecification-class is provided to the checkArgs function, the TypedSignature-class elements are searched sequentially until a matching one is found. That matching signature is returned. Therefore, the order the signatures are specified within the SimultaneousTypeSpecification-class object is important. This could change if we wanted. At present, it is up to the author to specify what they want to have happen. We could use the S4 signature matching technique when this is finalized and implemented in C code.

Usage

1
SimultaneousTypeSpecification(..., returnType, obj = new("SimultaneousTypeSpecification", list(...)))

Arguments

...

named TypedSignature objects. The names identify the parameter to which the type specification applies.

returnType

if supplied this should be an object of class ClassNameOrExpression-class.

obj

the instance of TypeSpecification-class that is to be populated with the content of ... and returnType.

Value

The return value is obj. By default, this has class SimultaneousTypeSpecification-class. It should be an object of class TypeSpecification-class.

Author(s)

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

See Also

IndependentTypeSpecification typeInfo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
foo =
function(x, y)
{
  x + y
}

typeInfo(foo) =
    SimultaneousTypeSpecification(
         TypedSignature(x = "integer", y = "integer"),
         TypedSignature(x = "numeric", y = "logical"))

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