From |@wrence@m|ch@e| @end|ng |rom gene@com  Tue Mar 19 18:12:16 2019
From: |@wrence@m|ch@e| @end|ng |rom gene@com (Michael Lawrence)
Date: Tue, 19 Mar 2019 10:12:16 -0700
Subject: [Rd] selectMethod() can fail to find methods in situations of
 multiple dispatch
In-Reply-To: <1abb17e0-12ee-57bb-b762-128552806fab@fredhutch.org>
References: <1abb17e0-12ee-57bb-b762-128552806fab@fredhutch.org>
Message-ID: <CAOQ5NyfqSZjr-MqHzYaaWoimZVYkt18oP-bZvFXpf4rNm+OZPQ@mail.gmail.com>

This is due to the intentional truncation of ANY suffixes from method
signatures. I've hacked selectMethod() to be robust to that and will commit
soon. Thanks for the report.

Michael

On Thu, Mar 14, 2019 at 9:32 AM Pages, Herve <hpages at fredhutch.org> wrote:

> Here is an example:
>
>   setGeneric("foo", function(x, y) standardGeneric("foo"))
>
>   setMethod("foo", c("numeric", "ANY"),
>     function(x, y) cat("I'm the foo#numeric#ANY method\n")
>   )
>
>
> Dispatch works as expected but selectMethod() fails to find the method:
>
>
>   > foo(1, TRUE)
>   I'm the foo#numeric#ANY method
>
>   > selectMethod("foo", c("numeric", "logical"))
>   Error in selectMethod("foo", c("numeric", "logical")) :
>     no method found for signature numeric, logical
>
> Adding an arbitrary method that doesn't have ANY in the signature "fixes"
> selectMethod():
>
>   setMethod("foo", c("complex", "integer"),
>     function(x, y) cat("I'm the foo#complex#integer method\n")
>   )
>
> Then:
>
>   > selectMethod("foo", c("numeric", "logical"))
>   Method Definition:
>
>   function (x, y)
>   cat("I'm the foo#numeric#ANY method\n")
>
>   Signatures:
>         x         y
>   target  "numeric" "logical"
>   defined "numeric" "ANY"
>
>
> Thanks,
>
> H.
>
>
> --
> Herv? Pag?s
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpages at fredhutch.org<mailto:hpages at fredhutch.org>
> Phone:  (206) 667-5791
> Fax:    (206) 667-1319
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] selectMethod() can fail to find methods in situations of multiple dispatch
Michael Lawrence