[Rcpp-devel] Checking for a promise

Gabor Grothendieck ggrothendieck at gmail.com
Sat Dec 25 02:10:17 CET 2010


How do I fix this so it works?  The code is intended to return TRUE or
FALSE according to whether the variable with name nm in environment
env is a promise or not.  In the example code below it returns FALSE
but I would like it to return TRUE.  Is the promise being forced
somewhere along the way?  Some other problem?

library(Rcpp)
f <- cxxfunction(signature(env="environment", nm = "character"),
        body=' Environment e(env);
           std::string s = as<std::string>(nm);
           return wrap(TYPEOF (e[s]) == PROMSXP); ',
        plugin="Rcpp")

# create promise
delayedAssign("prom", 3)

# want it to return TRUE but it returns FALSE
f(.GlobalEnv, "prom")


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


More information about the Rcpp-devel mailing list