Martin Maechler
1997-May-29 08:29 UTC
R-beta: WISH: For dyn.load()ing, I'd like is.loaded(.) , symbol.C, symbol.For
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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Luke Tierney
1997-May-29 15:53 UTC
R-beta: WISH: For dyn.load()ing, I'd like is.loaded(.) , symbol.C, symbol.For
Martin Maechler wrote:> > 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. >I'm a bit worried that this might impose too many restrictions on how dynamic loading is implemented. In particular it sort of assumes the S model where all symbols in dynamically loaded code are entered automatically in one global name space. With shared libraries a mechanism that allows you to explicitly import foo from libA and bar from libB may make more sense. The S design dates back to well before shared libraries became commonly available; before making a commitment to support the existing design it would be a good idea to consider all the options in light of what is supported by ELF shared libraries, Mac shared libraries and Windows DLL's and what seems most natural in terms of the common facilities they provide. Overall, I am not that thrilled with the S design in which you get a function pointer along with all the rope you need to hang yourself. I would prefer a scheme where you need to write a declarative interface stub that says something like myCfun<-make.Cfun("foo","libA", x="double *", n="int *", ...) which then goes away and generates the appropriate function with all the right as.whatever's needed to reduce the chance of nuking yourself if you don't get the arguments right (for the truly brave or those desparate for speed the low level implementation mechanism could be exposed too, but at least you wouldn't have to work at the raw function pointer level unless you choose to). As far as deciding whether something is loaded or needs to be loaded, I believe that would usually be much better handled by a module/dependency mechanism rather than by explicit loading commands in user code. Just my 2c worth. luke> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> 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 > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=->-- Luke Tierney University of Minnesota Phone: 612-625-7843 School of Statistics Fax: 612-624-8868 206 Church Street email: luke at stat.umn.edu Minneapolis, MN 55455 USA WWW: http://www.stat.umn.edu =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thomas Lumley
1997-May-29 16:17 UTC
R-beta: WISH: For dyn.load()ing, I'd like is.loaded(.) , symbol.C, symbol.For
On Thu, 29 May 1997, Martin Maechler wrote:> In S(plus), I can write functions using code fragments like > > if(!is.loaded(symbol.C("my_C_fun")))I was just about to send in exactly this request. Thomas Lumley ------------------------------------------------------+------ Biostatistics : "Never attribute to malice what : Uni of Washington : can be adequately explained by : Box 357232 : incompetence" - Hanlon's Razor : Seattle WA 98195-7232 : : ------------------------------------------------------------ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Seemingly Similar Threads
- R crashing after successfully running compiled code
- Undefined symbol when trying to dyn.load a shared object
- dyn.load error -- undefined symbol: ...
- dyn.load and/or add new package (Windows 98)
- Getting error ld: fatal: symbol `__SUNW_dof'' is multiply-defined: