From i.ucar86 at gmail.com  Wed Feb 21 14:16:52 2018
From: i.ucar86 at gmail.com (=?UTF-8?B?ScOxYWtpIMOaY2Fy?=)
Date: Wed, 21 Feb 2018 14:16:52 +0100
Subject: [Rd] How to modify dots and dispatch NextMethod
In-Reply-To: <CALEXWq2tL2qxLee_1MhRQcqmeUXe5BfnxCjZQM5RTkB7ccD7PA@mail.gmail.com>
References: <CALEXWq2tL2qxLee_1MhRQcqmeUXe5BfnxCjZQM5RTkB7ccD7PA@mail.gmail.com>
Message-ID: <CALEXWq1eSvjMxjsu9D+he3FYrpJhyMv9mhmWzVeyk7g8bbB5EQ@mail.gmail.com>

I've set up a repo with a reproducible example of the issue described
in my last email:

https://github.com/Enchufa2/dispatchS3dots

I?aki

2018-02-20 19:33 GMT+01:00 I?aki ?car <i.ucar86 at gmail.com>:
> Hi all,
>
> Not sure if this belongs to R-devel or R-package-devel. Anyways...
>
> Suppose we have objects of class c("foo", "bar"), and there are two S3
> methods c.foo, c.bar. In c.foo, I'm trying to modify the dots and
> forward the dispatch using NextMethod without any success. This is
> what I've tried so far:
>
> c.foo <- function(..., recursive=FALSE) {
>   dots <- list(...)
>   # inspect and modify dots
>   # ...
>   do.call(
>     function(..., recursive=FALSE) structure(NextMethod("c"), class="foo"),
>     c(dots, recursive=recursive)
>   )
> }
>
> foobar <- 1
> class(foobar) <- c("foo", "bar")
> c(foobar, foobar)
> Error: C stack usage  7970788 is too close to the limit
>
> There's recursion (!). But the funniest thing is that if c.foo is
> exported by one package and c.bar is exported by another one, there's
> no recursion, but c.bar is never called (!!). Why is the same code
> behaving in a different way depending on whether these functions are
> defined in the .GlobalEnv or in two attached packages? (BTW,
> isS3method() is TRUE, for c.foo and c.bar in both cases).
>
> I'm blocked here. Am I missing something? Is there a way of doing
> this? Thanks in advance.
>
> Regards,
> I?aki



-- 
I?aki ?car
http://www.enchufa2.es
@Enchufa2



[Rd] How to modify dots and dispatch NextMethod
=?UTF-8?B?ScOxYWtpIMOaY2Fy?=