jonthegeek / stbl

Stabilize Function Arguments
https://jonthegeek.github.io/stbl/
Other
14 stars 0 forks source link

empty vs NULL #45

Closed jonthegeek closed 1 year ago

jonthegeek commented 1 year ago

A thing being empty might be an indication that the higher-level object that uses it should also be empty. For the use case that led me to develop stbl, I really need to allow specifically this!

to_cls(cls()) works, but to_cls_scalar(cls()) errors, even if allow_na = TRUE.

How should I handle this? Should I differentiate between empty and NULL? Should I sometimes coerce NULL to empty (particularly in stabilize_*)?

Judging from actual use, I think I probably want to default to allowing empty for to_cls_scalar(), but NOT allowing NULL.

jonthegeek commented 1 year ago

I'm leaning toward something along these lines: an empty arg (or something like that) replaces allow_null (everywhere?). It has possible values along the lines of: c("coerce_to_vec", "coerce_to_null", "accept", "reject").