checkArgs
in the type validation for an R function.
When called, either implicitly or explicitly when the function
returns, it attempts to determine whether the value being
returned by the function call is valid relative
to the type information of the function and the call itself.
Specifically, it uses the signature of the current call to the
function if it is available (returned by checkArgs
)
to see if it has a specified return type. If so,
it compares the return value to that.
Otherwise, it checks to see if the return type for the
overall type info object (not just the specific type signature
for the call) is specified and then uses that to validate the
type. If neither is specified, then the value is not validated
and the value returned.
checkReturnValue(returnType, returnJump, sig, f = sys.function(-1))
value
. It must be explicitly given
in the call to checkReturnValue
and is used
to ensure that the return from checkReturnValue
returns from the calling function also in the case
that the value is valid. This is a piece of magic in R
that is very powerful using the lazy evaluation of the
arguments that allows us to return from the place that the
return
call was specified.
f
. This should have a returnType
slot
that contains class information or an expression. Otherwise,
the value is taken from the TypeSpecification-class
object for the entire function and its returnType
slot.
typeInfo
.returnType
is
available, the return value is value
.
Otherwise, if the validation fails, an error is raised.
checkArgs
TypeSpecification-class