The stopifnot_ma_safe2mutate() function
checks if an atomic object is actually safe to mutate.
The .internal_set_ma() function
sets an object to class 'mutatomic' by reference.
Examples
testfun1 <- function(x) {
.internal_set_ma(x)
}
x <- 1:10
is.mutatomic(x)
#> [1] FALSE
testfun1(x)
is.mutatomic(x) # FALSE, because it's ALTREP
#> [1] FALSE
x <- sample(1:10)
is.mutatomic(x)
#> [1] FALSE
testfun1(x)
is.mutatomic(x)
#> [1] TRUE
print(x)
#> [1] 2 8 10 6 7 1 5 3 4 9
#> mutatomic
#> typeof: integer