Re: [Rd] Enlightenment sought and a possible buglet in vector.Rd

From: Berwin A Turlach <>
Date: Mon 05 Dec 2005 - 04:23:47 GMT

G'day Brian,

>>>>> "BDR" == Prof Brian Ripley <> writes:

>> I found in the R language definition manual the passage that
>> discourages users of assigning objects within function calls
>> since it is not guaranteed that the assignment is ever made
>> because of R's lazy evaluation model. But this does not seem
>> to explain the above behaviour since the argument to print is
>> evaluated. If I replace sys.on.exit() with, say, ls() in both
>> functions, then they produce the same output (and the output
>> that I expect). Why does f2() not work with sys.on.exit()?

    BDR> It does work, but you seems to have misunderstood what it
    BDR> does.  See e.g.  the `bug' report discussed at
Mmh, mea culpa, I am a bit red-faced here, in my quest to find out what was going on, I checked about everything (including a private e-mail to an R-core member) but the bug repository and the help page of sys.on.exit(). I guess that if I have read the latter, I would have figured out what was going on. Instead I was satisfied with what the on.exit() help page stated in its "see also" section:
         \code{\link{sys.on.exit}} to see the current expression.

May I request that this help page is changed according to the patch attached below to clarify on the on.exit() help page what it is that sys.on.exit() is returning?

    BDR> You might find

    BDR> g <- function(test) {}
    BDR> f2 <- function(){
    BDR> par.def <- par(no.readonly=TRUE)
    BDR> on.exit(par(par.def))
    BDR> g(tt <- sys.on.exit())
    BDR> str(tt)
    BDR> invisible()
    BDR> }
    BDR> f2()

    BDR> illuminating.
Mmh, in this code the function g is not evaluating its argument. So I would expect an error message in f2() that tt is not defined no matter which function (sys.on.exit, ls, ...) I am using in the call to g() within f(). Exactly the situation about which the R language definition is warning, so this seems to be a different trap than the one I stepped into....



Index: src/library/base/man/on.exit.Rd mailing list Received on Mon Dec 05 15:29:28 2005

This archive was generated by hypermail 2.1.8 : Mon 05 Dec 2005 - 14:21:13 GMT