* On 2008-09-17 at 19:25 -0700 Seth Falcon wrote: > In the latest R-devel code (svn r46542), this behaves differently (and > works as you were hoping). I get: > > library("RSQLite") > setClass("SQLConPlus", contains=c("SQLiteConnection","integer")) > dd = data.frame(a=1:3, b=letters[1:3]) > con = new("SQLConPlus", dbConnect(SQLite(), ":memory:"), 11L) > dbWriteTable(con, "t1", dd) > dbListTables(con) > dbDisconnect(con)
*argh* I'm certain this was working for me and yet when I try to reproduce in a new R shell it errors out. The dispatch is not as I wrote. as(con, "integer") [1] 11 That is, the auto-generated coerce method to integer is selected in preference to the coerce method for SQLiteConnection. > I think the new behavior is desirable as it follows the rule that the > order of the superclasses listed in contains is used to break ties > when multiple methods match. Here, there are two coerce() methods > (invoked via as()) one for SQLiteConnection and one, I believe > auto-generated, for integer. Since SQLiteConnection comes first, it > is chosen. Indeed, if you try the following, you get the error you > were originally seeing: > > setClass("SQLConMinus", contains=c("integer", "SQLiteConnection")) > con2 = new("SQLConMinus", dbConnect(SQLite(), ":memory:"), 11L) > > > as(con, "integer") > [1] 15395 2 > > as(con2, "integer") > [1] 11 > > I'm still baffled how this was working for me and now is not. Nevertheless, I think it is how things *should* work and will do some further investigation about what's going on. -- Seth Falcon | http://userprimary.net/user/ ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel