is_internal_function: Is the input an internal function?

Description Usage Arguments Value References See Also Examples

View source: R/is-function.R

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

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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(){})
})

assertive.types documentation built on May 1, 2019, 10:31 p.m.