isClosure: Determine if a Worker Function is a Closure

Description Details Examples

View source: R/sleigh.R

Description

This is a heuristic function that is used by eachWorker and eachElem to guess if the worker function is a closure.

Details

If the closure option wasn't specified via the eo argument to eachWorker or eachElem, then this function is used to guess if the worker function is a closure. It can be very useful to use closures with eachWorker and eachElem, but if not used properly, you could accidentally include a lot of unnecessary data in the tasks, thus hurting your performance.

This function is included as a development tool so you can manually test your worker functions. This could be useful if you are getting a warning from eachWorker or eachElem, and are trying to determine how to modify the function or set the closure option.

Examples

1
2
3
4
5
6
# this should return FALSE
isClosure(sqrt)
f <- function(x) function(y) x + y
g <- f(1)
# this should return TRUE
isClosure(g)

nws documentation built on May 29, 2017, 11 p.m.

Search within the nws package
Search all R packages, documentation and source code