Open KellenBrosnahan opened 1 year ago
Sounds reasonable to me (but I am also not an S4 expert).
@hadley What do you think?
If we were to do that, we'd use setOldClass()
, but that sort of S4 manipulation can have unexpected and far reaching complications, so I wouldn't recommend it.
Hello, I am currently writing a package using the S4 OOP system, and was wondering whether there was an existing canonical way to memoize S4 methods. One of the errors I got was that
setMethod
cannot be passed a memoized function because the S3 classmemoised
is not technically an S4 class extendingfunction
, which is what theMethodDefinition
class (for S4 methods) requires:A simple workaround is to formally declare
memoised
to be an S4 class extendingfunction
via the following code:Is there a reason not to do this? Should this be part of the
memoise
package (assumingmethods
is loaded)?Here's a reprex: