Skip to content

S4 dispatch and S3 "connection" objects

4 messages · Michael Lawrence, John Chambers, Romain Francois

#
Hello,

I'm trying to get S4 dispatch on S3 "connection" objects.

So I do :

setOldClass( "connection" )

and then :

setGeneric( "bling", function(object) standardGeneric( "bling" ) )
setMethod( "bling", "connection", function(object) cat( "gotcha ", 
as.integer(object), "\n" ) )

but I get :

f <- file( "blabla", open = "rb" )

 > bling( f )
Error in function (classes, fdef, mtable)  :
   unable to find an inherited method for function "bling", for 
signature "file"
 > class( f )
[1] "file"       "connection"


Am I supposed to do :

setOldClass( c("file", "connection" ) )
setOldClass( c("url", "connection" ) )

and so on for each potential S3 class, or is there another way.

Romain
#
On 12/16/2009 12:52 AM, John Chambers wrote:
That'd be good.