Skip to content
Prev 26651 / 63424 Next

C/C++ 'assert' should not be used in R packages

Prof Brian Ripley wrote:
I partly disagree about this.  If assert() is triggered, it clearly 
indicates a bug in the package.  If it just generated an R error, most 
users would ignore it, and not report it to the package maintainer. 

It may well be that when an assertion fails, none of the subsequent 
calculations are reliable, in which case returning control to the user 
could result in data corruption.  That's worse than losing a session, 
because at least when you lose a session, you know it.

Could we write our own implementation of assert() that displays an R 
error and unloads the package?  I think I could do something like that 
in Windows by calling FreeLibrary to unload the DLL, but I'd prefer a 
cross-platform solution.
I'd say that's a bug, either in Mesa GL or in rgl.  If you can make it 
reproducible, I'll try to track it down.

Duncan Murdoch