Created
December 30, 2015 20:42
-
-
Save Hlynsson/8f1fda68075b7af54d50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> rm(list=ls()) | |
> someFunction <- function(x) { return(x*someVariable) } | |
> invisible(compiler::cmpfun(someFunction)) | |
Note: no visible binding for global variable 'someVariable' | |
# Scoping can be an issue: | |
> someVariable <- 1 | |
> invisible(compiler::cmpfun(someFunction)) | |
# No more error because of lexical scope, to solve: | |
> poorMansLibrary <- new.env() | |
> poorMansLibrary$someFunction <- someFunction | |
> rm(list=setdiff(ls(),"poorMansLibrary")) | |
> for(fn in names(poorMansLibrary)){ | |
out <- capture.output(invisible(compiler::cmpfun(poorMansLibrary[[fn]]))) | |
if(length(out)>0) { | |
cat("Warnings from function: ",fn,"\n",paste(out,sep="\n"),"\n",sep="") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment