Open lawremi opened 2 months ago
Should we pick a different name?
Currently, we have a strong convention that symbols with a class_
prefix are things that can be used as classes in new_class(parent=)
, new_property(class=)
, inherits(what=)
, etc. This name would break that pattern, probably leading to confusion.
> grep("^class_", getNamespaceExports("S7"), value = T)
[1] "class_POSIXct" "class_environment" "class_integer" "class_Date"
[5] "class_name" "class_double" "class_formula" "class_POSIXlt"
[9] "class_missing" "class_character" "class_language" "class_complex"
[13] "class_function" "class_list" "class_POSIXt" "class_vector"
[17] "class_factor" "class_call" "class_array" "class_numeric"
[21] "class_atomic" "class_expression" "class_matrix" "class_raw"
[25] "class_logical" "class_data.frame" "class_any"
This got me thinking: what if the base class proxies yielded the class_
prefix in this name clash?
I sketched out what that might look like in #461.
A new name would be a good idea. Perhaps just satisfies()
? This could be more about meeting some general constraint, not just inheritance.
Hi the utility function would definitely by handy if it got exported. Because you encounter it when defining your own container property where you need to test the type of child elements. So having an easy way to check if an object satisfies a wild class definition would be great. Which is now not really possible since the class definition can take many forms.
class_inherits()
is a useful utility for checking whether an object satisfies a class specification. I use the term specification, because I am not sure things like a class union orclass_any
are really classes (both are types of unions). But the fact that it's a specification makes it different frominherits()
.Should we export it? The name seems OK. In fact, it's better than
inherits()
, because objects do not inherit, classes do.We could also use something like
class_satisfies()
to distinguish it frominherits()
.