R-alpha: problems qith require/provide

Thomas Lumley thomas@biostat.washington.edu
Mon, 14 Apr 1997 13:44:12 -0700 (PDT)


On Tue, 15 Apr 1997, Ross Ihaka wrote:

> Thomas has sent me a new version which may fix this problem.  I will
> take a look.
It doesn't completely.  A better solution is to do as Kurt suggested and 
put 
.Provided<-character(0)
in Rprofile.  The code at the end of this message then works.

Re: :=
The loss of := is not a problem now we know about it (I used sed to 
convert, Kurt used emacs), it was just a bit of a surprise at the time.
It's a good idea to get it killed off *before* we go to a beta version.


libraries:
R source files in the funs/ directory of a library are not used if their 
names begin with a capital letter [eg Rsurvival4, Rgee, Rdate  ;-)]

- thomas
--------------------------------------------------------------
require<- function (name, quietly = FALSE) 
{
  if (missing(name)) 
    return(TRUE)  
  name <- substitute(name)
  if (!is.character(name)) 
	  name <- deparse(name)
  if (is.na(match(name, .Libraries))&& is.na(match(name, .Provided))) {
    file <- system.file("library", name)
    if (file == "") {
      if (!quietly) 
	warning(paste("Required library ", name, " not found.\n"))
      return(FALSE)
    }
    if (!quietly) 
      cat("Autoloading required library:", name, "\n")
    sys.source(file)
    assign(".Libraries", c(name, .Libraries), NULL)
  }
  return(TRUE)
}


provide<-function(name)
{
  if (missing(name)) {
    return(list(provide=.Provided, library=.Libraries))
  }
  name<-substitute(name)
  if (!is.character(name))
    name<-deparse(name)
  if (is.na(match(name, .Libraries)) && is.na(match(name, .Provided))){
    assign(".Provided",c(name,.Provided),environment(NULL))
    return(TRUE)
  } 
  else 
    return(FALSE)
}
  

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-