Pages, Herve
2019-Mar-22 03:14 UTC
[Rd] selectMethod() can fail to find methods in situations of multiple dispatch
Hi Michael, Thanks for looking into this. I suspect that truncation of ANY suffixes from method signatures is also the culprit behind the sudden breakage of aliases of the form \alias{foo,numeric-method} when a method without the ANY suffix in its signature gets added to the ecosystem. See my post about this to the Bioc-devel mailing list a couple of months ago: https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014603.html So overall isn't this truncation more trouble than it's worth? H. On 3/19/19 10:12, Michael Lawrence wrote: 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<mailto: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><mailto: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<mailto:R-devel at r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-devel<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=4e2MsIBoF9YnF3BCkiOk1m2kFgKBe24FwU28c-wuAyc&s=ydXNxAwEa5eG9lTu27sx-8KsT6gU66TbmJLcaYEaleg&e=> -- 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]]
Michael Lawrence
2019-Mar-22 04:29 UTC
[Rd] selectMethod() can fail to find methods in situations of multiple dispatch
If we started over, I'd try to avoid this sort of complexity, but "ANY" truncation has been happening since at least 2003.> matchSignature(c("numeric", "ANY"), foo)x "numeric" So I'm not sure we want to mess with it. Michael On Thu, Mar 21, 2019 at 8:14 PM Pages, Herve <hpages at fredhutch.org> wrote:> Hi Michael, > > Thanks for looking into this. I suspect that truncation of ANY suffixes > from method signatures is also the culprit behind the sudden breakage of > aliases of the form \alias{foo,numeric-method} when a method without the > ANY suffix in its signature gets added to the ecosystem. See my post about > this to the Bioc-devel mailing list a couple of months ago: > https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014603.html > > So overall isn't this truncation more trouble than it's worth? > > H. > On 3/19/19 10:12, Michael Lawrence wrote: > > 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 >> <https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=4e2MsIBoF9YnF3BCkiOk1m2kFgKBe24FwU28c-wuAyc&s=ydXNxAwEa5eG9lTu27sx-8KsT6gU66TbmJLcaYEaleg&e=> >> > -- > 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 > Phone: (206) 667-5791 > Fax: (206) 667-1319 > >[[alternative HTML version deleted]]
Pages, Herve
2019-Mar-22 04:52 UTC
[Rd] selectMethod() can fail to find methods in situations of multiple dispatch
Fine with me as long as eliminating the inconveniences associated with it can be put on the roadmap. The alias instability and the fact that the user has no way to know if s/he should do ?`foo,numeric-method` or ?`foo,numeric,ANY-method` to find the method has been a long-standing problem. H. On 3/21/19 21:29, Michael Lawrence wrote: If we started over, I'd try to avoid this sort of complexity, but "ANY" truncation has been happening since at least 2003.> matchSignature(c("numeric", "ANY"), foo)x "numeric" So I'm not sure we want to mess with it. Michael On Thu, Mar 21, 2019 at 8:14 PM Pages, Herve <hpages at fredhutch.org<mailto:hpages at fredhutch.org>> wrote: Hi Michael, Thanks for looking into this. I suspect that truncation of ANY suffixes from method signatures is also the culprit behind the sudden breakage of aliases of the form \alias{foo,numeric-method} when a method without the ANY suffix in its signature gets added to the ecosystem. See my post about this to the Bioc-devel mailing list a couple of months ago: https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014603.html<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_pipermail_bioc-2Ddevel_2019-2DJanuary_014603.html&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=kjmNpPtpGtaMCrw8ubpy0siyz1xl8WY9gONjtL65IxE&s=R9Hi4Rm4nk-izYC8vDCj0NiuFdUMG4vZVbdQgsvxkDM&e=> So overall isn't this truncation more trouble than it's worth? H. On 3/19/19 10:12, Michael Lawrence wrote: 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<mailto: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><mailto: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<mailto:R-devel at r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-devel<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=4e2MsIBoF9YnF3BCkiOk1m2kFgKBe24FwU28c-wuAyc&s=ydXNxAwEa5eG9lTu27sx-8KsT6gU66TbmJLcaYEaleg&e=> -- 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 -- 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]]
Apparently Analagous Threads
- selectMethod() can fail to find methods in situations of multiple dispatch
- selectMethod() can fail to find methods in situations of multiple dispatch
- selectMethod() can fail to find methods in situations of multiple dispatch
- selectMethod() can fail to find methods in situations of multiple dispatch
- selectMethod() can fail to find methods in situations of multiple dispatch