checkArgs: Validate the arguments in a call to a typed function.

Description Usage Arguments Value Author(s) See Also Examples


TypeInfo uses checkArgs internally.

This function is used to validate the arguments in a call to a function that has associated type information about the parameters. The types for the parameters are currently given associated with the function via an attribute "ParameterTypes". In the body of the function, one can call checkArgs and the specification is taken and used to compute whether the elements in the call are compatible with those in the signatures.

There are currently several ways to specify the signatures. One is as a list of explicit parameter name - class name pair vectors given as c(paramName = className, paramName = className, ...). Alternatively, one can use an expression to perform a dynamic test. For example, one can test the length of an object, e.g. c(x = length(x) < 4, y = length(y) == length(x)). Each expression should return a logical value indicating whether the expected condition was satisfied. A third form of specifying signatures is given using class names for individual parameters and just matching the argument class to these names. This differs from the first form because the arguments are not checked simultaneoulsy, but rather one at a time. The test for a given argument is whether it is in the named vector of classes.


checkArgs(f = sys.function(1), argNames, args = NULL, forceAll = FALSE,
          env = sys.frame(1), isMissing = logical(0))



the function object. If this is missing, the function is taken as the function being called in the previous frame, i.e. the one that called checkArgs.


a character vector giving the names of the arguments that are to be checked.


a list of named argument values.


a logical value. If this is TRUE, then we evaluate all of the arguments in the call frame of the function being evaluated whose arguments we are to check. If this is FALSE, This should be a three-level enum to represent evaluate as needed, evaluate all referenced in any of the signatures and evaluate all of the arguments now.


the environment in which arguments are located.


named logical vector indicating missing formal arguments; defined internally when consulting f of class function



If the check succeeds in matching the arguments to the parameter types, the signature that matched is returned. Otherwise, an error is raised. If the signature is returned, this can be used to validate the return value in the context of that signature.

Note that if an instance of SimultaneousTypeSpecification-class is provided to this 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.


Duncan Temple Lang <[email protected]>

See Also



bob = function(x, y) {
        checkArgs()  # Completely unecessary as we don't specify type information.

 # a call generates a warning to say that there was no type information.

Bioconductor-mirror/TypeInfo documentation built on June 1, 2017, 3:25 a.m.