Displaying 20 results from an estimated 20000 matches similar to: "About the method dispatch mechanism"
2018 Mar 27
2
Objects not gc'ed due to caching (?) in R's S3 dispatch mechanism
I have committed a change to R-devel that addresses this. To be on the
safe side I need to run some more extensive tests before deciding if
this can be ported to the release branch for R 3.5.0. Should know in a
day or two.
Best,
luke
On Tue, 27 Mar 2018, luke-tierney at uiowa.edu wrote:
> This has nothing to do with printing or dispatch per se. It is the
> result of an internal register
2018 Mar 26
4
Objects not gc'ed due to caching (?) in R's S3 dispatch mechanism
Hi,
I initially opened an issue in the R6 repo because my issue was with
an R6 object. But Winston (thanks!) further simplified my example, and
it turns out that the issue (whether a feature or a bug is yet to be
seen) had to do with S3 dispatching.
The following example, by Winston, depicts the issue:
print.foo <- function(x, ...) {
cat("print.foo called\n")
invisible(x)
}
2010 Sep 07
1
Dispatch method on S3 or S4 class
Hello,
I've been attempting to make a generic method that dispatches on the first argument, which can be either an S3 or an S4 class. This is as far as I've gotten. Any suggestions about what to try next ?
library(aroma.affymetrix)
library(GenomicRanges)
setGeneric("analyse", function(x, y, ...) standardGeneric("analyse"))
setMethodS3("analyse",
1999 Apr 14
5
R's UseMethod() does not dispatch on changed class() (PR#167)
(opening new bug report thread, on suggestion of BDR ..)
I said on vaguely related topic:
MM> There's another long-standing
MM> UseMethod / NextMethod / Dispatch problem that I've never traced/solved..
MM>
MM> Look at the $RHOME/tests/mode-methods.R file !
Peter Dalgaard already remarked :
PD> ..i.e. this:
PD> abc <- function(x, ...) {
PD> if
2010 Apr 27
1
suggestion on method dispatch
Dear all, I have define a function and its methods as follows:
######## beginning of code
fn <- function(x,...){
UseMethod("fn")
}
fn.foo1 <- function(x, commonA=1, ...){
print("fn.foo1 is called.")
}
fn.foo2 <- function(x, uniqueFoo2, common=1, ...){
## uniqueFoo2 is a unique argument in fn.foo2
x <- uniqueFoo2; class(x) <- "foo1"
## use uniqueFoo2
2018 Mar 27
2
Objects not gc'ed due to caching (?) in R's S3 dispatch mechanism
2018-03-27 6:02 GMT+02:00 <luke-tierney at uiowa.edu>:
> This has nothing to do with printing or dispatch per se. It is the
> result of an internal register (R_ReturnedValue) being protected. It
> gets rewritten whenever there is a jump, e.g. by an explicit return
> call. So a simplified example is
>
> new_foo <- function() {
> e <- new.env()
>
2006 Sep 27
1
S3 methods for cbind/rbind
I created a type of object similar to a data frame. In some circumstances, It
needs special methods for "[" and "[<-" and rbind() (but not cbind()). Then I
found this in the cbind()/rbind() man page:
The method dispatching is _not_ done via 'UseMethod()', but by
C-internal dispatching. Therefore, there is no need for, e.g.,
'rbind.default'.
2018 Mar 27
0
Objects not gc'ed due to caching (?) in R's S3 dispatch mechanism
This has nothing to do with printing or dispatch per se. It is the
result of an internal register (R_ReturnedValue) being protected. It
gets rewritten whenever there is a jump, e.g. by an explicit return
call. So a simplified example is
new_foo <- function() {
e <- new.env()
reg.finalizer(e, function(e) message("Finalizer called"))
e
}
bar <- function(x)
2019 May 14
2
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
CCing r-devel.
On Tue, 14 May 2019 at 02:11, Pavel Krivitsky <pavel at uow.edu.au> wrote:
>
> Dear All,
>
> I've run into this while updating a package with unfortunately named
> legacy functions. It seems like something that might be worth changing
> in R, and I want to get a sense of whether this is a problem before
> submitting a report to the Bugzilla.
>
>
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
2016 Apr 19
2
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
See also .isMethodsDispatchOn, which is what trace uses to decide if the
methods package needs to be loaded.
~G
On Tue, Apr 19, 2016 at 5:34 AM, Michael Lawrence <lawrence.michael at gene.com
> wrote:
> Not sure why R_has_methods_attached() exists. Maybe Martin could shed
> some light on that.
>
> On Mon, Apr 18, 2016 at 11:50 PM, Kirill M?ller
> <kirill.mueller at
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
2016 Apr 18
3
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Scenario: An S3 method is declared for an S4 base class but called for
an instance of a derived class.
Steps to reproduce:
> Rscript -e "test <- function(x) UseMethod('test', x); test.Matrix <-
function(x) 'Hi'; MatrixDispatchTest::test(Matrix::Matrix())"
Error in UseMethod("test", x) :
no applicable method for 'test' applied to an
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
2016 Apr 19
4
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Does it make sense to be able to load an S4 object without the methods
package being attached? I'm not sure implementation-wise how easy this
would be, but it seems like any time there is an S4 object around, the
methods package should be available to deal with it.
~G
On Tue, Apr 19, 2016 at 7:34 AM, Michael Lawrence <lawrence.michael at gene.com
> wrote:
> Right,
2024 Apr 20
2
passing a modified argument to an S3 method
I do not understand what your goal is here (more context may be helpful,
perhaps to others rather than me). So I doubt this is what you want, but
here is a guess -- no need to respond if it is unhelpful:
## test.default returns NULL if object "y" not found in **calling
environment and enclosures**;
## otherwise y.
test <- function(x){
UseMethod("test")
}
test.default
2018 Mar 27
1
Objects not gc'ed due to caching (?) in R's S3 dispatch mechanism
2018-03-27 11:11 GMT+02:00 Tomas Kalibera <tomas.kalibera at gmail.com>:
> On 03/27/2018 09:51 AM, I?aki ?car wrote:
>>
>> 2018-03-27 6:02 GMT+02:00 <luke-tierney at uiowa.edu>:
>>>
>>> This has nothing to do with printing or dispatch per se. It is the
>>> result of an internal register (R_ReturnedValue) being protected. It
>>> gets
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
2016 Apr 19
3
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Thanks for looking into it, your approach sounds good to me. See also
R_has_methods_attached()
(https://github.com/wch/r-source/blob/42ecf5f492a005f5398cbb4c9becd4aa5af9d05c/src/main/objects.c#L258-L265).
I'm fine with Rscript not loading "methods", as long as everything works
properly with "methods" loaded but not attached.
-Kirill
On 19.04.2016 04:10, Michael
Suggestion for exception handling: More informative error message for "no applicable method..." (S3)
2009 Oct 20
1
Suggestion for exception handling: More informative error message for "no applicable method..." (S3)
I'd like to suggest that whenever there is no S3 method implementation
available for a particular class, that the error message would also
report the class structure of the object dispatched on.
Example:
foo <- function(...) UseMethod("foo")
foo.ClassA <- function(object, ...) { cat("foo() for ClassA called.\n") }
> foo(structure(1, class="ClassA"))
2012 Oct 17
1
Do *not* pass '...' to NextMethod() - it'll do it for you; missing documentation, a bug or just me?
Hi,
although I've done S3 dispatching for more than a decade now, I think
I managed to overlook/avoid the following pitfall when using
NextMethod():
If you explicitly pass argument '...' to NextMethod(), you will
effectively pass those argument twice to the "next" method!
EXAMPLE:
foo0 <- function(...) UseMethod("foo0");
foo1 <- function(...)
2020 Jan 21
2
class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch
Dear Martin,
What's the ETA for _R_CLASS_MATRIX_ARRAY_=TRUE to become the new
unconditional behavior in R devel? Thanks!
H.
On 11/21/19 08:57, Martin Maechler wrote:
>
> TLDR: This is quite technical, still somewhat important:
> 1) R 4.0.0 will become a bit more coherent: a matrix is an array
> 2) Your package (or one you use) may be affected.
>
>
2020 May 12
4
S3 method dispatch for methods in local environments
Dear All,
In R 3.6.3 (and earlier), method dispatch used to work for methods stored in local environments that are attached to the search path. For example:
myfun <- function(y) {
out <- list(y=y)
class(out) <- "myclass"
return(out)
}
print.myclass <- function(x, ...) print(formatC(x$y, format="f", digits=5))
myfun(1:4)
# prints: [1]
2007 Jun 28
1
Method dispatch in functions?
Hi,
Could someone point me in the right direction for documentation on the following question?
Let's say I have two objects a and b of classes A and B, respectively.
Now let's say I write a function foo that does something similar to
objects of type A and B. Basically I want to overload the function
in C++ talk, so if I give foo and object of type A something (and this
is my question)