From murdoch@dunc@n @end|ng |rom gm@||@com  Mon Mar 11 14:32:31 2024
From: murdoch@dunc@n @end|ng |rom gm@||@com (Duncan Murdoch)
Date: Mon, 11 Mar 2024 09:32:31 -0400
Subject: [Rd] R6 "classname" and generator name
In-Reply-To: <CANVKczP7UBx4b9=qXeBHXbf4S4p_MG+S50VPJ7_ze8Rj3U20DQ@mail.gmail.com>
References: <CANVKczP7UBx4b9=qXeBHXbf4S4p_MG+S50VPJ7_ze8Rj3U20DQ@mail.gmail.com>
Message-ID: <91b89e18-424c-4613-90cd-7a172a3276e2@gmail.com>

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



[Rd] R6 "classname" and generator name
Duncan Murdoch