Skip to content
Prev 38079 / 63424 Next

Loading Cached Weaver Objects

On 10/19/2010 08:33 PM, Dario Strbenac wrote:
Hi Dario

Probably useful to ask the maintainer
packageDescription('weaver')$Maintainer. But from looking at the package
code I see

eval_and_cache <- function(sexpr, deps, cacheEnv, cachefile, quiet) {
    if (!quiet)
      cat("  COMPUTING... ", file=stderr())
    log_debug("computing...")
    ## We want to pick up inherited stuff during the eval.  So no
    ## parent=emptyenv().
    eval(sexpr, envir=cacheEnv)
    DEPS <- deps
    SESSION <- sessionInfo()
    save(cacheEnv, DEPS, SESSION, file=cachefile)
    if (!quiet)
      cat("done.\n", file=stderr())
}


load_from_cache_env <- function(fromEnv, toEnv, hash, sym2hash, updated) {
    ## The 'updated' arg is a logical flag.  TRUE indicates that
    ## syms in fromEnv were retrieved from cache but had to be
    ## recomputed because of a dependency mismatch.  This is allows
    ## us to detect second order dependency mismatch where the
    ## expression doesn't change, but we've recomputed.
    syms <- ls(fromEnv)
    for (sym in syms) {
        assign(sym, fromEnv[[sym]], envir=toEnv)
        assign(sym, list(hash=hash, updated=updated), envir=sym2hash)
    }
}

so would guess that 'cacheEnv' is a environment that contains the result
of evaluating the code in the chunk.

Hope that helps,

Martin