[Rd] Using IDs to suppress specific messages and warnings

Duncan Murdoch murdoch.duncan at gmail.com
Thu Sep 10 15:18:49 CEST 2015


On 10/09/2015 9:03 AM, Richard Cotton wrote:
> Thanks Luke,
> 
> On 10 September 2015 at 14:47,  <luke-tierney at uiowa.edu> wrote:
>> Conditions have classes and the condition system is designed around
>> the idea that classes would be used for this sort of thing. That is
>> already how tryCatch and withCallingHandlers discriminate the
>> conditions to handle.
> 
> That makes sense.  Though with my sqrt example, it's just a plain
> simpleWarning, which doesn't give you the opportunity to do special
> handling.
> 
> tryCatch(sqrt(-1), warning = function(w) class(w))
> ## [1] "simpleWarning" "warning"       "condition"
> 
> 
>> Designing and implementing a condition class hierarchy to support this
>> is indeed the hard/tedious part.
> 
> There are precedents from other languages that could be used as a
> template.  For example, .NET and Java both have very well defined
> exception hierarchies that could serve as a starting point.
> 
> https://msdn.microsoft.com/en-us/library/z4c5tckx%28v=vs.110%29.aspx
> https://docs.oracle.com/javase/7/docs/api/java/lang/package-tree.html
> 
> Who is the best person to ask/cajole to start getting this implemented?

I think that if you put together a proposal that looks easy to implement
and maintain, and volunteered (or recruited volunteers) to do most of
the work, then it would get done.  I don't think either of the posted
hierarchies would be acceptable, though, because they'd require anyone
who was writing new code to learn them.

Currently if I want to put in a warning, it's easy:  I just call
warning().  If you make it take an extra 5 seconds to add something that
makes the warning more useful, I'd do it.  If it takes 10 minutes of
reading through voluminous documentation, I wouldn't.

Duncan Murdoch



More information about the R-devel mailing list