checkmate
checkmate copied to clipboard
pairlist.ok argument in assertList()
assertList(x)
throws an error if x
is a pairlist
object. From the base-R point of view, this is unexpected:
# create a pairlist
p <- pairlist(x = 1)
class(p)
# p is a list according to base R
base::is.list(p)
# p is not a list according to checkmate
checkmate::testList(p)
One might argue that a pairlist is a special list which should not be considered as a list by default, but in this case this should be documented in ?assertList.
Note that this is not an issue of unevaluated symbols in a list:
a <- alist(x = not_existing_variable)
testList(a)
An easy workaround would be to introduce a new argument to checkList
: pairlist.ok = FALSE
so that it does not affect existing code. Later the default could be changed to TRUE
.
You are totally right. I have documented this behavior until I find some time to fix this (pairlists are strangely implemented in C).