Skip to content
Prev 5848 / 12125 Next

[R-pkg-devel] Package can't be imported with Suggests

Dirk,

This sounds familiar: in package 'bit' for  

bit | bitwhich 

R did neither S3-dispatch to "|.bit" nor to "|.bitwhich" but nonsensically to the default method. 

It took me a while to reverse my class thinking enough to realize that I could get control by forcing dispatch to a common class 'booltype'.  So far this sounds harmless. But the truth is that to make this work 'booltype' must not be a common superclass but needs to be a subclass of 'bit' in bit-objects and needs to be a subclass of 'bitwhich' in bitwhich-objects. Only then the dispatch to "|.booltype" dominates and we get a seemingly conflict-free dispatch to "|.booltype" which then resolves possible conflicts. I hope using R's S3 class system upside-down does not introduce "another problem". Citing from "Beautiful Code":

"
it is worth bringing our discussion to an end by noting that Lampson attributes the aphorism that started our exploration (all problems in computer science can be solved by another level of indirection) to David Wheeler, the inventor of the subroutine. Significantly, Wheeler completed his quote with another phrase: "But that usually will create another problem."
"

Best

Jens



#