[R] setGeneric(rm)

Paul Roebuck roebuck at odin.mdacc.tmc.edu
Fri Dec 3 21:09:51 CET 2004

On Fri, 3 Dec 2004, Marcos Carrero wrote:

> We are developing a package using S4 classes. The S4 classes are
> wrappers to C++ classes. So S4 classes contain an integer that is the
> memory address of one C++ object. If an user calls the rm() function,
> the C++ object must be deleted. But our generic rm() function apparently
> doesn't work. Here is the code:
> # The class
> setClass("component", representation(pointer="integer", "VIRTUAL"))
> # The generic method
> setGeneric("rm", function(..., list = object, pos = -1,
>                           envir = as.environment(pos),
>                           inherits = FALSE)  standardGeneric("rm"))
> setMethod("rm", "component", function(list=object, pos, envir, inherits) {
> 	warning("object deleted")
> 	.Call("Rm");i
> })
> We implemented generic methods for print(), show() and summary() succesfully.

The method signatures don't match. Does the warning message
actually display?

BTW, isn't it dangerous to assume a pointer and integer
occupy the same amount of storage?

SIGSIG -- signature too long (core dumped)

More information about the R-help mailing list