On 11/03/2024 8:15 a.m., Barry Rowlingson wrote:> I'm writing some code that does a bit of introspection of R6 classes
and am
> wondering about the "classname" parameter. Its the first
parameter to the
> "R6Class" class generator generator function, and the few
examples I've
> looked at on CRAN set it the same as the name of the generator function,
> for example, from the docs:
>
> Queue <- R6Class("Queue", .....)
>
> but this isn't mandatory, it can be anything. Or NULL. (side quest: do
> linters exist that flag this as bad style?).
>
> Does anyone have an example of a CRAN package where this isn't the
case? Or
> even where an R6 class generator uses the default "NULL" for its
classname
> parameter? My introspection code is in two minds whether to use the
> classname to label diagrams of classes, or to use the names of the actual
> generator functions (which are what the package users should be using), or
> show both if different, or flag up NULL values etc...
>
> Never should have opened this can of worms. I don't even like worms.
Here's an example:
https://github.com/saraswatmks/superml/blob/0d7f6aea09968267a11612475424d4635d57877c/R/RandomSearch.R#L11-L12
I don't have any idea if this is intentional or not.
Duncan Murdoch