From roebuck at odin.mdacc.tmc.edu  Tue Jul 19 22:21:10 2005
From: roebuck at odin.mdacc.tmc.edu (Paul Roebuck)
Date: Tue, 19 Jul 2005 15:21:10 -0500 (CDT)
Subject: [Rd] S4 Dispatching
Message-ID: <Pine.OSF.4.58.0507191505420.84377@odin.mdacc.tmc.edu>

Is it possible for S4 to (continue) dispatch to a class
created during dispatching? The code below doesn't work;
is this not possible or have I ommitted something?

Concept was to create a SEXP with R_AllocatePtr, give it
a class attribute, and continue dispatch. Example code
below omits multiple parameters that can be different types.
Essentially, any parameter would be converted to an
internal type "class" and the final dispatch would be
passing EXTPTRSXP objects.


library(methods)

setGeneric("onthefly",
           function(mydata) {
    cat("generic", match.call()[[1]], "\n")
    standardGeneric("onthefly")
})

setMethod("onthefly",
          signature(mydata = "character"),
          function(mydata) {
    cat(match.call()[[1]],
        "(character)\n")

    # Simulating EXTPTRSXP
    mydata <- list(name = "mydata")
    class(mydata) <- "mydata"

    callGeneric(mydata)
})

setMethod("onthefly",
          signature(mydata = "mydata"),
          function(mydata) {
    cat(match.call()[[1]],
        "(mydata)\n")

    str(mydata)
})



> version
         _
platform powerpc-apple-darwin7.9.0
arch     powerpc
os       darwin7.9.0
system   powerpc, darwin7.9.0
status
major    2
minor    1.1
year     2005
month    06
day      20
language R

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)



[Rd] S4 Dispatching
Paul Roebuck