As far as I can see sys.on.exit() does not work. The following
will give a non-null result in S, and seems about the simplest possible
usage.
test <- function() {
on.exit(print(1))
ex <- sys.on.exit()
str(ex)
cat("exiting...\n")
}> test()
NULL
exiting...
[1] 1
Looking at the code suggests that on.exit is installing the code in
a different context from the one sys.on.exit is looking in, but this is
daunting for non-experts.
The help page does not say what this is supposed to do, of course, but
I assume it is intended to retrieve the on.exit expression, as in S.
--please do not edit the information below--
Version:
platform = sparc-sun-solaris2.6
arch = sparc
os = solaris2.6
system = sparc, solaris2.6
status =
status.rev = 0
major = 0
minor = 65.0
year = 1999
month = August
day = 27
language = R
Search Path:
.GlobalEnv, Autoloads, package:base
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk writes:> As far as I can see sys.on.exit() does not work. The following > will give a non-null result in S, and seems about the simplest possible > usage. > > test <- function() { > on.exit(print(1)) > ex <- sys.on.exit() > str(ex) > cat("exiting...\n") > } > > test() > NULL > exiting... > [1] 1 > > Looking at the code suggests that on.exit is installing the code in > a different context from the one sys.on.exit is looking in, but this is > daunting for non-experts.Not really that hard, once I realised that R_GlobalContext is not a global constant and that R_ToplevelContext is the bottom of the context stack... sys.on.exit is a function that calls a .Internal. This inserts an extra context layer - calling the .Internal directly works - and one just had to look one level further up. Will commit for 0.65.1 in a moment. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Reasonably Related Threads
- Rprof and setMethod conflict?
- cbind is not generic as claimed, omits labels where S has them (PR#239)
- maketitle garbles the title in package nnet (PR#613)
- outer fails with group generic operations on factors (PR#166)
- glm gives incorrect results for zero-weight cases (PR#780)