From luke at stat.uiowa.edu  Mon Aug 27 16:42:36 2007
From: luke at stat.uiowa.edu (Luke Tierney)
Date: Mon, 27 Aug 2007 09:42:36 -0500 (CDT)
Subject: [Rd] silent option in nested calls to try()
In-Reply-To: <46D2DDCB.6060008@tu-dresden.de>
References: <46D2C659.90208@tu-dresden.de>
	<Pine.LNX.4.64.0708270815060.2819@itasca.stat.uiowa.edu>
	<46D2DDCB.6060008@tu-dresden.de>
Message-ID: <Pine.LNX.4.64.0708270934400.4484@nokomis.stat.uiowa.edu>

Your best option is to contact the author of the software and ask them
to use silent = TRUE or try to play some games with output capture.

try() is an old interface that has been reimplemented on top of
tryCatch.  It could be modified to, for example, use message(), which
would then allow messages to be suppressed with suppressMessages, but
this leaves the issue of warnings (see the try() code).  Coming up
with something that behaves sensibly would require a considerable
design effort.  I don't see the effort as warranted at this point.

The choice of silent=TRUE as the default is I believe unfortunate but
it has been so for many years.  Again I don't see the effort in
changing this as warranted at this point.

Best,

luke

On Mon, 27 Aug 2007, Thomas Petzoldt wrote:

> Dear Luke,
>
> thank you very much for your immediate answer. The problem I see is, however, 
> that while one can rewrite ones outer code using tryCatch, one may not have 
> control over the use of try in a given inner function.
>
> Thomas
>
>
>
> Luke Tierney wrote:
>> Yes.  If you want finer control use tryCatch.
>> 
>> Best,
>> 
>> luke
>> 
>> On Mon, 27 Aug 2007, Thomas Petzoldt wrote:
>> 
>>> Hello,
>>> 
>>> is it *really intentional* that the "silent" option of try() does only
>>> apply to the outer call in nested try constructs? I would assume that a
>>> silent try() should suppress all error messages regardless where they
>>> occur, even if they are already handled with other try()'s.
>>> 
>>> The error message itself should be (and is in both cases) reported by
>>> the return value of try().
>>> 
>>> Thanks in advance
>>> 
>>> Thomas
>>> 
>>> 
>>> ## Old behavior (tested with R-2.4.1):
>>> >  try(try(exp(NULL)), silent=TRUE)
>>> >
>>> 
>>> 
>>> ## Current behavior (R-2.6.0 unstable, build 42641, WinXP):
>>> >  try(try(exp(NULL)), silent=TRUE)
>>> Error in exp(NULL) : Non-numeric argument to mathematical function
>>> >
>>> 
>>> 
>>> 
>>> 
>> 
>
>

-- 
Luke Tierney
Chair, 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:      luke at stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] silent option in nested calls to try()
Luke Tierney