>>>>> Hervé Pagès 
>>>>>     on Fri, 19 May 2023 11:43:50 -0700 writes:

    > Hi,

    > Just ran across this:

    >     foo <- function(x, ..., z=22) z

    >     setMethod("foo", "character", function(x, y=-5, z=22) y)
    >     # Creating a generic function from function ‘foo’ in the global 
    > environment

    > Then:

    >     foo("a")
    >     # [1] 22

    > Should return -5, not 22.

    > That's because the call to .local() used internally by the foo() method 
    > does not name the arguments placed after the ellipsis:

    >> selectMethod("foo", "character")
    > Method Definition:

    > function (x, ..., z = 22)
    > {
    >     .local <- function (x, y = 5, z = 22)
    >     y
    >     .local(x, ..., z)  <--- should be .local(x, ..., z=z)
    > }

    > Thanks,
    > H.


    >> sessionInfo()
    > R version 4.3.0 (2023-04-21)
  [...............]

I can confirm this *bug*  (also in R 4.2.z, R 4.1.z, R 3.6.3).

One might be tempted to say this falls into the
  "Doctor, it hurts when I do this --- then, don't do that!"
category.

Maybe a simple way to fix the would be to  forbid the  '...'
in S4 generics and methods apart from at the end,
or then make sure that after the ...  in the .local() call, all
argument must be named  {{as you suggest above}}.

Could you file a bug at R's bugzilla?
{I know we have too many open bugs there, notably related to S4,
 but still you'd do a service to the R community.}

Best,
Martin




    > -- 
    > Hervé Pagès

    > Bioconductor Core Team
    > hpages.on.git...@gmail.com

    > _______________________________________________
    > Bioc-devel@r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/bioc-devel

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to