nCompiler
nCompiler copied to clipboard
R CMD check issue with use of nClass member variables in nClass functions
If I have this basic nClass code in a function in a "user" package, R CMD check complains that Rv and Cv can't be found as global variables.
Nothing we need to deal with now probably. Just flagging this for future consideration.
myfun <- function(x, v=7) {
nc <- nClass(
Rpublic = list(
Rv = NULL,
Rfoo = function(x) x+Rv
),
Cpublic = list(
Cv = 'numericScalar',
Ca = 'numericVector',
Cfoo = nFunction(
fun = function(x) {
return(x+Cv)
},
argTypes = list(x = 'numericScalar'),
returnType = 'numericScalar')
)
)
Robj <- nc$new()
Cnc <- nCompile(nc)
Cobj <- Cnc$new()
Cobj$Cv <- v
Cobj2 <- Cnc$new()
Cobj2$Cv <- v+1
return(c(Cobj$Cfoo(x), Cobj2$Cfoo(x)))
}
* checking R code for possible problems ... NOTE
myfun : <anonymous>: no visible binding for global variable ‘Rv’
myfun : <anonymous>: no visible binding for global variable ‘Cv’
Undefined global functions or variables:
Cv Rv