Quantcast

Problems with S4 methods dispatching on `...` (aka dotsMethods)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problems with S4 methods dispatching on `...` (aka dotsMethods)

Andrzej Oleś
Hi all,

I recently encountered some unexpected behavior with S4 generics
dispatching on `...`, which I described in
http://stackoverflow.com/questions/43499203/use-callnextmethod-with-dotsmethods

TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`, and
arguments of such methods are resolved differently than the arguments of
methods dispatching on formal arguments.

Could this indicate a potential problem with the implementation of the
`...` dispatch?

Cheers,
Andrzej

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems with S4 methods dispatching on `...` (aka dotsMethods)

Michael Lawrence-3
Thanks for pointing out these issues. I have a fix that I will commit soon.

Btw, I would never have seen the post on Stack Overflow. It's best to
report bugs on the bugzilla.

Michael

On Thu, Apr 20, 2017 at 8:30 AM, Andrzej Oleś <[hidden email]> wrote:

> Hi all,
>
> I recently encountered some unexpected behavior with S4 generics
> dispatching on `...`, which I described in
> http://stackoverflow.com/questions/43499203/use-callnextmethod-with-dotsmethods
>
> TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`, and
> arguments of such methods are resolved differently than the arguments of
> methods dispatching on formal arguments.
>
> Could this indicate a potential problem with the implementation of the
> `...` dispatch?
>
> Cheers,
> Andrzej
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems with S4 methods dispatching on `...` (aka dotsMethods)

Andrzej Oleś
Great, thanks Michael for you quick response!

I started off with a question on SO because I was not sure whether this was
an actual bug or I was just missing something obvious. I'm looking forward
to the patch.

Cheers,
Andrzej


On Thu, Apr 20, 2017 at 10:28 PM, Michael Lawrence <
[hidden email]> wrote:

> Thanks for pointing out these issues. I have a fix that I will commit soon.
>
> Btw, I would never have seen the post on Stack Overflow. It's best to
> report bugs on the bugzilla.
>
> Michael
>
> On Thu, Apr 20, 2017 at 8:30 AM, Andrzej Oleś <[hidden email]>
> wrote:
> > Hi all,
> >
> > I recently encountered some unexpected behavior with S4 generics
> > dispatching on `...`, which I described in
> > http://stackoverflow.com/questions/43499203/use-callnextmethod-with-
> dotsmethods
> >
> > TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`,
> and
> > arguments of such methods are resolved differently than the arguments of
> > methods dispatching on formal arguments.
> >
> > Could this indicate a potential problem with the implementation of the
> > `...` dispatch?
> >
> > Cheers,
> > Andrzej
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems with S4 methods dispatching on `...` (aka dotsMethods)

Andrzej Oleś
Hi Michael,

thanks again for your patch! I've tested it and I'm happy to confirm that
`callNextMethod()` works with methods dispatching on `...`.

However, the second issue I reported still seems to be unresolved. Consider
the following toy example, where the `f()` calls differ in result depending
on whether the dispatch happens on a formal argument or the `...` argument.


    f = function(x, ..., a = b) {
      b = "missing 'a'"
      print(a)
    }

    f()
    ## [1] missing 'a'

    f(a = 1)
    ## [1] 1

    setGeneric("f", signature = "x")

    # works as the non-generic version
    f()
    ## [1] missing 'a'

    setGeneric("f", signature = "...")

    # unexpectedly fails to find 'b'
    f()
    ## Error in print(a) : object 'b' not found


Any chances of fixing this?

Cheers,
Andrzej


On Fri, Apr 21, 2017 at 11:40 AM, Andrzej Oleś <[hidden email]>
wrote:

> Great, thanks Michael for you quick response!
>
> I started off with a question on SO because I was not sure whether this
> was an actual bug or I was just missing something obvious. I'm looking
> forward to the patch.
>
> Cheers,
> Andrzej
>
>
> On Thu, Apr 20, 2017 at 10:28 PM, Michael Lawrence <
> [hidden email]> wrote:
>
>> Thanks for pointing out these issues. I have a fix that I will commit
>> soon.
>>
>> Btw, I would never have seen the post on Stack Overflow. It's best to
>> report bugs on the bugzilla.
>>
>> Michael
>>
>> On Thu, Apr 20, 2017 at 8:30 AM, Andrzej Oleś <[hidden email]>
>> wrote:
>> > Hi all,
>> >
>> > I recently encountered some unexpected behavior with S4 generics
>> > dispatching on `...`, which I described in
>> > http://stackoverflow.com/questions/43499203/use-callnextmeth
>> od-with-dotsmethods
>> >
>> > TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`,
>> and
>> > arguments of such methods are resolved differently than the arguments of
>> > methods dispatching on formal arguments.
>> >
>> > Could this indicate a potential problem with the implementation of the
>> > `...` dispatch?
>> >
>> > Cheers,
>> > Andrzej
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems with S4 methods dispatching on `...` (aka dotsMethods)

Michael Lawrence-3
I attempted to fix it, and that example seems to work for me. It's
also a (passing) regression test in R. Are you sure you're using a new
enough R-devel?


On Tue, Apr 25, 2017 at 2:34 AM, Andrzej Oleś <[hidden email]> wrote:

> Hi Michael,
>
> thanks again for your patch! I've tested it and I'm happy to confirm that
> `callNextMethod()` works with methods dispatching on `...`.
>
> However, the second issue I reported still seems to be unresolved. Consider
> the following toy example, where the `f()` calls differ in result depending
> on whether the dispatch happens on a formal argument or the `...` argument.
>
>
>     f = function(x, ..., a = b) {
>       b = "missing 'a'"
>       print(a)
>     }
>
>     f()
>     ## [1] missing 'a'
>
>     f(a = 1)
>     ## [1] 1
>
>     setGeneric("f", signature = "x")
>
>     # works as the non-generic version
>     f()
>     ## [1] missing 'a'
>
>     setGeneric("f", signature = "...")
>
>     # unexpectedly fails to find 'b'
>     f()
>     ## Error in print(a) : object 'b' not found
>
>
> Any chances of fixing this?
>
> Cheers,
> Andrzej
>
>
>
> On Fri, Apr 21, 2017 at 11:40 AM, Andrzej Oleś <[hidden email]>
> wrote:
>>
>> Great, thanks Michael for you quick response!
>>
>> I started off with a question on SO because I was not sure whether this
>> was an actual bug or I was just missing something obvious. I'm looking
>> forward to the patch.
>>
>> Cheers,
>> Andrzej
>>
>>
>> On Thu, Apr 20, 2017 at 10:28 PM, Michael Lawrence
>> <[hidden email]> wrote:
>>>
>>> Thanks for pointing out these issues. I have a fix that I will commit
>>> soon.
>>>
>>> Btw, I would never have seen the post on Stack Overflow. It's best to
>>> report bugs on the bugzilla.
>>>
>>> Michael
>>>
>>> On Thu, Apr 20, 2017 at 8:30 AM, Andrzej Oleś <[hidden email]>
>>> wrote:
>>> > Hi all,
>>> >
>>> > I recently encountered some unexpected behavior with S4 generics
>>> > dispatching on `...`, which I described in
>>> >
>>> > http://stackoverflow.com/questions/43499203/use-callnextmethod-with-dotsmethods
>>> >
>>> > TL;DR: `callNextMethod()` doesn't work in methods dispatching on `...`,
>>> > and
>>> > arguments of such methods are resolved differently than the arguments
>>> > of
>>> > methods dispatching on formal arguments.
>>> >
>>> > Could this indicate a potential problem with the implementation of the
>>> > `...` dispatch?
>>> >
>>> > Cheers,
>>> > Andrzej
>>> >
>>> >         [[alternative HTML version deleted]]
>>> >
>>> > ______________________________________________
>>> > [hidden email] mailing list
>>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems with S4 methods dispatching on `...` (aka dotsMethods)

Andrzej Oleś
You're right, I must have mixed up my R versions when running the example,
as the problem seems to be resolved in R-devel.

Sorry for the noise and thanks again for fixing this.

Andrzej

On Tue, Apr 25, 2017 at 3:55 PM, Michael Lawrence <[hidden email]
> wrote:

> I attempted to fix it, and that example seems to work for me. It's
> also a (passing) regression test in R. Are you sure you're using a new
> enough R-devel?
>
>
> On Tue, Apr 25, 2017 at 2:34 AM, Andrzej Oleś <[hidden email]>
> wrote:
> > Hi Michael,
> >
> > thanks again for your patch! I've tested it and I'm happy to confirm that
> > `callNextMethod()` works with methods dispatching on `...`.
> >
> > However, the second issue I reported still seems to be unresolved.
> Consider
> > the following toy example, where the `f()` calls differ in result
> depending
> > on whether the dispatch happens on a formal argument or the `...`
> argument.
> >
> >
> >     f = function(x, ..., a = b) {
> >       b = "missing 'a'"
> >       print(a)
> >     }
> >
> >     f()
> >     ## [1] missing 'a'
> >
> >     f(a = 1)
> >     ## [1] 1
> >
> >     setGeneric("f", signature = "x")
> >
> >     # works as the non-generic version
> >     f()
> >     ## [1] missing 'a'
> >
> >     setGeneric("f", signature = "...")
> >
> >     # unexpectedly fails to find 'b'
> >     f()
> >     ## Error in print(a) : object 'b' not found
> >
> >
> > Any chances of fixing this?
> >
> > Cheers,
> > Andrzej
> >
> >
> >
> > On Fri, Apr 21, 2017 at 11:40 AM, Andrzej Oleś <[hidden email]>
> > wrote:
> >>
> >> Great, thanks Michael for you quick response!
> >>
> >> I started off with a question on SO because I was not sure whether this
> >> was an actual bug or I was just missing something obvious. I'm looking
> >> forward to the patch.
> >>
> >> Cheers,
> >> Andrzej
> >>
> >>
> >> On Thu, Apr 20, 2017 at 10:28 PM, Michael Lawrence
> >> <[hidden email]> wrote:
> >>>
> >>> Thanks for pointing out these issues. I have a fix that I will commit
> >>> soon.
> >>>
> >>> Btw, I would never have seen the post on Stack Overflow. It's best to
> >>> report bugs on the bugzilla.
> >>>
> >>> Michael
> >>>
> >>> On Thu, Apr 20, 2017 at 8:30 AM, Andrzej Oleś <[hidden email]>
> >>> wrote:
> >>> > Hi all,
> >>> >
> >>> > I recently encountered some unexpected behavior with S4 generics
> >>> > dispatching on `...`, which I described in
> >>> >
> >>> > http://stackoverflow.com/questions/43499203/use-callnextmethod-with-
> dotsmethods
> >>> >
> >>> > TL;DR: `callNextMethod()` doesn't work in methods dispatching on
> `...`,
> >>> > and
> >>> > arguments of such methods are resolved differently than the arguments
> >>> > of
> >>> > methods dispatching on formal arguments.
> >>> >
> >>> > Could this indicate a potential problem with the implementation of
> the
> >>> > `...` dispatch?
> >>> >
> >>> > Cheers,
> >>> > Andrzej
> >>> >
> >>> >         [[alternative HTML version deleted]]
> >>> >
> >>> > ______________________________________________
> >>> > [hidden email] mailing list
> >>> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> >>
> >
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Loading...