From h.wickham at gmail.com  Wed Aug 27 16:48:30 2014
From: h.wickham at gmail.com (Hadley Wickham)
Date: Wed, 27 Aug 2014 09:48:30 -0500
Subject: [Rd] no visible binding for global variable for data sets in a
	package
In-Reply-To: <D13961DB-34D8-4A33-B01E-D8F8BECCB501@gmail.com>
References: <53FD030A.1020709@yorku.ca>
	<21501.41940.216907.982935@stat.math.ethz.ch>
	<53FDDD55.1040807@yorku.ca> <53FDE608.40801@yorku.ca>
	<D13961DB-34D8-4A33-B01E-D8F8BECCB501@gmail.com>
Message-ID: <CABdHhvE1NVHibz6rzcRzcdeRZMA2gjCzzEkiE7eENoTSE5=+1Q@mail.gmail.com>

> I think the right answer _is_ to export the lazy data; the question is how to do it. There's nothing particularly strange about exporting non-functions ("letters" would be an example, save for the special status of package:base). If you attach the package, the lazyloaded data appear in the same environment as the exported function so they are de facto already in the namespace for the purposes of library() and `::`. So I agree, something like exportData() would be useful. (Or some other mechanism. You might want to be able to export data selectively.)

I don't think lazyloaded data are in the same environment as exported
functions - getExportedValue() (called by ::) looks first in the
"exports" namespace, then in the "lazydata" namespace:

function (ns, name)
{
    getInternalExportName <- function(name, ns) {
        exports <- getNamespaceInfo(ns, "exports")
        if (exists(name, envir = exports, inherits = FALSE))
            get(get(name, envir = exports, inherits = FALSE),
                envir = ns)
        else {
            ld <- getNamespaceInfo(ns, "lazydata")
            if (exists(name, envir = ld, inherits = FALSE))
                get(name, envir = ld, inherits = FALSE)
            else stop(gettextf("'%s' is not an exported object from
'namespace:%s'",
                name, getNamespaceName(ns)), call. = FALSE, domain = NA)
        }
    }
    ns <- asNamespace(ns)
    if (isBaseNamespace(ns))
        get(name, envir = ns, inherits = FALSE)
    else getInternalExportName(name, ns)
}


(But maybe you just meant the library() and :: behaves as is lazydata
and exports were the same thing)

Hadley

-- 
http://had.co.nz/



[Rd] no visible binding for global variable for data sets in a package
Hadley Wickham