Re: [Rd] as.list fails on functions with S3 classes

2021-04-29 Thread Martin Maechler
> brodie gaslam via R-devel > on Thu, 29 Apr 2021 01:04:01 + (UTC) writes: >> On Wednesday, April 28, 2021, 5:16:20 PM EDT, Gabriel Becker wrote: >> >> Hi Antoine, >> >> I would say this is the correct behavior. S3 dispatch is solely (so far as >> I kn

Re: [Rd] as.list fails on functions with S3 classes

2021-04-28 Thread Gabriel Becker
On Wed, Apr 28, 2021 at 6:04 PM brodie gaslam wrote: > > > On Wednesday, April 28, 2021, 5:16:20 PM EDT, Gabriel Becker < > gabembec...@gmail.com> wrote: > > > > > The analogous case for non-closures to what you are describing would be > for > > S3 to check mode(x) after striking out with class(x

Re: [Rd] as.list fails on functions with S3 classes

2021-04-28 Thread brodie gaslam via R-devel
> On Wednesday, April 28, 2021, 5:16:20 PM EDT, Gabriel Becker > wrote: > > Hi Antoine, > > I would say this is the correct behavior. S3 dispatch is solely (so far as > I know?) concerned with the "actual classes" on the object. This is because > S3 classes act as labels that inform dispatch wh

Re: [Rd] as.list fails on functions with S3 classes

2021-04-28 Thread Gabriel Becker
Hi Antoine, I would say this is the correct behavior. S3 dispatch is solely (so far as I know?) concerned with the "actual classes" on the object. This is because S3 classes act as labels that inform dispatch what, and in what order, methods should be applied. You took the function class (ie label

[Rd] as.list fails on functions with S3 classes

2021-04-28 Thread Antoine Fabri
Dear R devel, as.list() can be used on functions, but not if they have a S3 class that doesn't include "function". See below : ```r add1 <- function(x) x+1 as.list(add1) #> $x #> #> #> [[2]] #> x + 1 class(add1) <- c("function", "foo") as.list(add1) #> $x #> #> #> [[2]] #> x + 1 class(add1)