Put together a list and we can see what might make sense.  If we did
take this on it would be good to think about providing a reasonable
mechanism for addressing the small flaw in this function as it is
defined here.

Best,

luke

On Wed, 27 Apr 2011, Hadley Wickham wrote:

This has the side effect of ignoring errors
and even hiding the error messages.  If you
are concerned about multiple calls to on.exit()
in one function you could define a new function
like
 withOptions <- function(optionList, expr) {
  oldOpts <- options(optionList)
  on.exit(options(oldOpts))
  expr # lazily evaluate
 }

I wish R had more functions like this.  This sort of behaviour is also
useful when you open connections or change locales.  Ruby's blocks
provide nice syntactic sugar for this idea.

Hadley



--
Luke Tierney
Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
   Actuarial Science
241 Schaeffer Hall                  email:      l...@stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to