SimultaneousTypeSpecification {TypeInfo} | R Documentation |
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.
SimultaneousTypeSpecification(..., returnType, obj = new("SimultaneousTypeSpecification", list(...)))
... |
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 . |
The return value is obj
.
By default, this has class SimultaneousTypeSpecification-class
.
It should be an object of class TypeSpecification-class
.
Duncan Temple Lang <duncan@wald.ucdavis.edu>
IndependentTypeSpecification
typeInfo
foo = function(x, y) { x + y } typeInfo(foo) = SimultaneousTypeSpecification( TypedSignature(x = "integer", y = "integer"), TypedSignature(x = "numeric", y = "logical"))