From berwin at maths.uwa.edu.au  Mon Dec  5 05:23:47 2005
From: berwin at maths.uwa.edu.au (Berwin A Turlach)
Date: Mon, 5 Dec 2005 12:23:47 +0800
Subject: [Rd] Enlightenment sought and a possible buglet in vector.Rd
In-Reply-To: <Pine.LNX.4.61.0512021120450.25330@gannet.stats>
References: <17296.8817.937646.30624@bossiaea.maths.uwa.edu.au>
	<Pine.LNX.4.61.0512021120450.25330@gannet.stats>
Message-ID: <17299.49363.577811.326018@bossiaea.maths.uwa.edu.au>

G'day Brian,

>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk> 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
    BDR> http://tolstoy.newcastle.edu.au/~rking/R/devel/05/02/2112.html
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:

     \seealso{
         \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....

Cheers,

        Berwin

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: R-patch
Url: https://stat.ethz.ch/pipermail/r-devel/attachments/20051205/78465d21/R-patch.ksh


[Rd] Enlightenment sought and a possible buglet in vector.Rd
Berwin A Turlach