[R] on.exit processing

Luke Tierney luke at nokomis.stat.umn.edu
Tue Sep 11 14:00:00 CEST 2001


Replacing

 		ctxt->conexit = listAppend(oldcode,tmp);

in builtin.c:do_onexit with

 		ctxt->conexit = listAppend(duplicate(oldcode),tmp);

fixes this bug.  It is fixed in the development tree and should be in
the next release.

If you need to work around the bug before then, make sure the first
on.exit expression you register does not have braces around it.

luke

> On Mon, Sep 10, 2001 at 11:01:39AM -0400, james.holtman at convergys.com wrote:
> > I have encountered a 'strange' behavior in the 'on.exit' processing.  I had
> > a function where I setup an 'on.exit' condition and then later on added to
> > it with an 'on.exit({...}, add=T)'.  What appeared to happen is that on
> > subsequent calls to the function, even if only the first 'on.exit' was
> > called, it was still executing the one with the 'add=T'.
> > 
> > I am using Version 1.3.0  (2001-06-22) on Windows 2000.
> > 
> > Here is a small sample of what is happening.  The function conditionally
> > sets up the on.exit, and as you can see, each time the 'second' one is
> > setup, it just keeps adding to what is output:
> > 
> > 
> > > x.func <- function(x=0){
> > +     on.exit({cat('first exit call\n')})
> > +     if (x == 1) on.exit({cat('second exit call\n')}, add=T)
> > +     invisible(NULL)
> > + }
> > > x.func(0)   # only the 'first' exit
> > first exit call
> > > x.func(1)   # both 'first' & 'second'
> > first exit call
> > second exit call
> > > x.func(0)   # only the 'first'
> > first exit call
> > second exit call         #<<  shouldn't be here
> > > x.func(1)   # both 'first' & 'second'
> > first exit call
> > second exit call
> > second exit call         #<<  shouldn't be here
> > > x.func(1)   # both 'first' & 'second'
> > first exit call
> > second exit call
> > second exit call         #<<  shouldn't be here
> > second exit call         #<<  shouldn't be here
> > > x.func(1)   # both 'first' & 'second'
> > first exit call
> > second exit call
> > second exit call         #<<  shouldn't be here
> > second exit call         #<<  shouldn't be here
> > second exit call         #<<  shouldn't be here
> > >
> > 
> > --
> > 
> > NOTICE:  The information contained in this electronic mail transmission is
> > intended by Convergys Corporation for the use of the named individual or
> > entity to which it is directed and may contain information that is
> > privileged or otherwise confidential.  If you have received this electronic
> > mail transmission in error, please delete it from your system without
> > copying or forwarding it, and notify the sender of the error by reply email
> > or by telephone (collect), so that the sender's address records can be
> > corrected.
> > 
> > 
> > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> > 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
> 313 Ford Hall, 224 Church St. S.E.           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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Luke Tierney
University of Minnesota                      Phone:           612-625-7843
School of Statistics                         Fax:             612-624-8868
313 Ford Hall, 224 Church St. S.E.           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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list