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.
1 2 |
f |
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 |
argNames |
a character vector giving the names of the arguments that are to be checked. |
args |
a list of named argument values. |
forceAll |
a logical value. If this is |
env |
the environment in which arguments are located. |
isMissing |
named logical vector indicating missing formal
arguments; defined internally when consulting |
.
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 <duncan@wald.ucdavis.edu>
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.