assert_is_internal_function {assertive.types}R Documentation

Is the input an internal function?

Description

Checks to see if the input is an internal function. That is, it is a non-primitive function that calls C-code via .Internal.

Usage

assert_is_internal_function(x, severity = getOption("assertive.severity",
  "stop"))

is_internal_function(x, .xname = get_name_in_parent(x))

Arguments

x

Input to check.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used directly.

Value

is_internal_function returns TRUE when the input is a closure function that calls .Internal. The assert_* function returns nothing but throw an error if the corresponding is_* function returns FALSE.

References

This function is modeled upon is_internal, internal to the pryr package. The differences between the .Internal and .Primitive interfaces to C code are discussed in R-Internals, in the chapter Internal vs. Primitive. https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#g_t_002eInternal-vs-_002ePrimitive

See Also

is.function and its assertive wrapper is_function.

Examples

# Some common fns calling .Internal
is_internal_function(unlist)
is_internal_function(cbind)

# Some failures
assertive.base::dont_stop({
assert_is_internal_function("unlist")
assert_is_internal_function(sqrt)
assert_is_internal_function(function(){})
})

[Package assertive.types version 0.0-3 Index]