R-beta: WISH: For dyn.load()ing, I'd like is.loaded(.) , symbol.C, symbol.For

Martin Maechler maechler at stat.math.ethz.ch
Thu May 29 10:29:37 CEST 1997


In S(plus), I can write functions using code fragments like

	if(!is.loaded(symbol.C("my_C_fun")))
		dyn.load("......../my_C_fun.o")
	r <- .C("my_C_fun",
		x = x,
		n = n, 
		...
		)


which I would like to have in R, too.

The S-plus help page on this subject says :

S+>> Code Availability
S+>> 
S+>> DESCRIPTION:
S+>>        is.loaded returns a logical value  stating  if  the  given
S+>>        object   is  currently  loaded  into  S-PLUS.  dump.loaded
S+>>        returns a list of loaded symbols.  The "symbol"  functions
S+>>        return the symbol that would be associated with a name.
S+>> 
S+>> USAGE:
S+>>        is.loaded(symbol)
S+>>        dump.loaded()
S+>>        symbol.C(name)
S+>>        symbol.For(name)
S+>>        symbol.S(name)
S+>> 
S+>> REQUIRED ARGUMENTS:
S+>> symbol:    a  symbol,  typically  the  result  of   symbol.C   or
S+>>        symbol.For.
S+>> name:     a character string giving the name of a subroutine.
S+>> 
S+>> VALUE:
S+>>        is.loaded returns a logical  value:  it  is  TRUE  if  the
S+>>        symbol  is  found  in  the  S-PLUS  symbol table and FALSE
S+>>        otherwise.  symbol.C returns  the  symbol  that  would  be
S+>>        produced  by  a C function named name.  symbol.For returns
S+>>        the symbol that would be produced by a Fortran  subroutine
S+>>        named  name.   symbol.S  returns  the symbol that would be
S+>>        produced by an old-S  function  named  name.   dump.loaded
S+>>        returns  a  list  with two components, symbol and address,
S+>>        giving the names and addresses of all cached symbols (this
S+>>        is  a  superset  of  all  dyn.loaded functions).  Applying
S+>>        is.loaded to any symbol in this list should return TRUE.
S+>> 
S+>> DETAILS:
S+>>        These functions  are  mainly  useful  for  writing  S-PLUS
S+>>        functions  that  will automatically dyn.load code if it is
S+>>        not loaded already.  The S-PLUS function can be  the  same
S+>>        whether  the  code  is  statically  loaded  or dynamically
S+>>        loaded.
S+>> 
S+>>        The symbol.S function is only useful for  those  who  have
S+>>        old-S  (S-PLUS  version 1.x) functions (not macros) and do
S+>>        not wish to convert them to .Fortran calls.
S+>> 
S+>> SEE ALSO:
S+>>        dyn.load, dyn.load2, LOAD, .Fortran, .S.
S+>> 
S+>> EXAMPLES:
S+>>        if (!is.loaded(symbol.C("mbol")))
S+>>                       dyn.load("/usr/mabel/mbol.o")
S+>>        .C("mbol",as.double(x),as.integer(length(x)))
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help 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-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the R-help mailing list