rlang icon indicating copy to clipboard operation
rlang copied to clipboard

`is_dictionarish(NULL)` should return `TRUE`

Open hadley opened this issue 1 year ago • 2 comments

I think, because there are no names, hence the names are necessarily unique.

hadley avatar May 17 '24 14:05 hadley

On the other hand NULL is not a vector.

vctrs::vec_is(NULL)
#> [1] FALSE

is_vector(NULL)
#> [1] FALSE

On the other other hand, you can take the names and length of NULL:

names(NULL)
#> NULL

I'm just wondering what kind of invariants we can attribute to dictionaryish objects. Is it just that they have a length and names, and the names are unique?

This would be consistent with:

is_dictionaryish(env())
#> [1] TRUE

Do you remember what you needed this for? Having some examples of patterns that would be simplified by adding this special-case for NULL would be helpful to understand the relevant invariants.

lionel- avatar May 31 '24 11:05 lionel-

I don't, but I suspect it was an argument where the default was NULL and the expected type was a list.

hadley avatar May 31 '24 12:05 hadley