Permalink
Browse files

clean up mentions/usage of .First.lib

remove packloader.R, now unused


git-svn-id: https://svn.r-project.org/R/trunk@56391 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information...
ripley
ripley committed Jul 16, 2011
1 parent b444488 commit d6c89152e3cdac54d3f79c474e8ecb73f23934b9
View
@@ -710,13 +710,11 @@ escapes should not be used unless the package depends on @code{R (>=
usable in some locales and may display incorrectly in others.
-@findex .First.lib
-@findex .Last.lib
@findex library.dynam
Various @R{} functions in a package can be used to initialize and
-clean up. @xref{Load hooks}.@footnote{Up to R
+clean up. @xref{Load hooks}.@footnote{Up to @R{}
version 2.14.0, the @code{.First.lib} and @code{.Last.lib} functions
-handled these tasks in packages without namespaces. (In current R
+handled these tasks in packages without namespaces. (In current @R{}
versions, @emph{all} packages have namespaces.) To help with
conversion of old packages, here is how they were handled: It was
conventional to define these functions in a file called @file{zzz.R}.
View
@@ -2493,8 +2493,8 @@ passes control to @code{loadNamespace}. Then @code{library} or
is not found and otherwise sources the code (using @code{sys.source})
into the package's environment, then lazy-loads a database
@file{R/sysdata} if present. So how @R{} code gets loaded depends on
-the contents of @file{R/@var{pkgname}}: standard templates to load
-lazy-load databases are provided in @file{share/R/[ns]packloader.R}.
+the contents of @file{R/@var{pkgname}}: a standard template to load
+lazy-load databases are provided in @file{share/R/nspackloader.R}.
How (and if) compiled code is loaded is down to the package's startup
code such as @code{.First.lib} or @code{.onLoad}, although a
View
@@ -1,18 +0,0 @@
-.First.lib <- function(libname, pkgname)
-{
- fullName <- paste("package", pkgname, sep=":")
- myEnv <- as.environment(match(fullName, search()))
- barepackage <- sub("([^-]+)_.*", "\\1", pkgname)
- dbbase <- file.path(libname, pkgname, "R", barepackage)
- rm(.First.lib, envir = myEnv)
- lazyLoad(dbbase, myEnv)
- if(exists(".First.lib", envir = myEnv, inherits = FALSE)) {
- f <- get(".First.lib", envir = myEnv, inherits = FALSE)
- if(is.function(f))
- f(libname, pkgname)
- else
- stop(gettextf("package '%s' has a non-function '.First.lib'",
- pkgname),
- domain = NA)
- }
-}
@@ -19,6 +19,7 @@ attach <- function(what, pos = 2, name = deparse(substitute(what)),
{
checkConflicts <- function(env)
{
+ ## remove .First.lib eventually (no longer used nor exported)
dont.mind <- c("last.dump", "last.warning", ".Last.value",
".Random.seed", ".First.lib", ".Last.lib",
".packageName", ".noGenerics", ".required",
@@ -56,6 +56,7 @@
\alias{.ImportFrom}
\alias{.Export}
\alias{.S3method}
+\alias{.First.lib}
%
\description{
The functions or variables listed here are no longer part of \R as
@@ -145,6 +146,9 @@ manglePackageName(pkgName, pkgVersion)
.Export(...)
.S3method(generic, class, method)
% </Removed 2.13.0>
+% Removed in 2.14.0
+.First.lib(lib, pkg)
+% </Removed 2.14.0>
}
\details{
\code{category} has been an old-S function before there were factors;
@@ -241,6 +245,9 @@ manglePackageName(pkgName, pkgVersion)
\code{.Import}, \code{.ImportFrom}, \code{.Export} and
\code{.S3method} were part of an experimental alternative way to
specify namespaces.
+
+ \code{.First.lib} was the load/attach hook for packages without
+ namespaces: use \code{\link{.onLoad}} or \code{\link{.onAttach}} instead.
}
\seealso{
\code{\link{Defunct}}, \code{\link{base-deprecated}}
@@ -7,7 +7,6 @@
\title{Loading and Listing of Packages}
\alias{library}
\alias{require}
-\alias{.First.lib}
\alias{.noGenerics}
\alias{print.libraryIQR}
@@ -33,9 +32,7 @@ require(package, lib.loc = NULL, quietly = FALSE,
whether \code{character.only} is \code{FALSE} (default) or
\code{TRUE}).}
\item{pos}{the position on the search list at which to attach the
- loaded package. Note that \code{.First.lib} may attach other
- packages, and \code{pos} is computed \emph{after} \code{.First.lib}
- has been run. Can also be the name of a position on the current
+ loaded package. Can also be the name of a position on the current
search list as given by \code{\link{search}()}.}
\item{lib.loc}{a character vector describing the location of \R
library trees to search through, or \code{NULL}. The default value
@@ -202,11 +199,6 @@ detach(pos = match(paste("package", pkg, sep=":"), search()))
require(nonexistent) # FALSE
\dontrun{
-## Suppose a package needs to call a DLL named 'fooEXT',
-## where 'EXT' is the system-specific extension. Then you should use
-.First.lib <- function(lib, pkg)
- library.dynam("foo", pkg, lib)
-
## if you want to mask as little as possible, use
library(mypkg, pos = "package:base")
}}
@@ -1610,7 +1610,7 @@ newClassRepresentation <- function(...) {
value
}
-## the real version of newClassRepresentation, assigned in .First.lib
+## the real version of newClassRepresentation, assigned in ..First.lib
.newClassRepresentation <- function(...)
new("classRepresentation", ...)
@@ -16,15 +16,15 @@
.TkUp <- FALSE
-.onLoad <- function(lib, pkg)
+.onLoad <- function(libname, pkgname)
{
## This will get interrupted if there is no display,
## so we choose to have the space here.
packageStartupMessage("Loading Tcl/Tk interface ...", " ",
domain = "R-tcltk", appendLF = FALSE)
## Use local = FALSE to allow easy loading of Tcl extensions
- library.dynam("tcltk", pkg, lib, local = FALSE)
+ library.dynam("tcltk", pkgname, libname, local = FALSE)
.TkUp <<- .C("tcltk_init", 0L, PACKAGE="tcltk")[[1L]] == 1L
addTclPath(system.file("exec", package = "tcltk"))
packageStartupMessage("done", domain = "R-tcltk")
@@ -14,5 +14,5 @@
# A copy of the GNU General Public License is available at
# http://www.r-project.org/Licenses/
-.First.lib <- function(lib, pkg)
+.onLoad <- function(libname, pkgname)
stop("Tcl/Tk support is not available on this system", domain = "R-tcltk")
@@ -33,7 +33,7 @@ code2LazyLoadDB <-
ns <- loadNamespace(package, lib.loc, keep.source, TRUE, TRUE)
makeLazyLoadDB(ns, dbbase, compress = compress)
}
- else
+ else
stop("all packages should have a NAMESPACE")
}
@@ -268,10 +268,8 @@ makeLazyLoading <-
if (package == "base")
stop("this cannot be used for package 'base'")
- else if (packageHasNamespace(package, dirname(pkgpath)))
- loaderFile <- file.path(R.home("share"), "R", "nspackloader.R")
- else
- loaderFile <- file.path(R.home("share"), "R", "packloader.R")
+
+ loaderFile <- file.path(R.home("share"), "R", "nspackloader.R")
codeFile <- file.path(pkgpath, "R", barepackage)
if (!file.exists(codeFile)) {

0 comments on commit d6c8915

Please sign in to comment.