Skip to content
Prev 25906 / 63421 Next

methods and try() [R-devel]

On 8/16/07, Luke Tierney <luke at stat.uiowa.edu> wrote:
An indeed, I believe I've got one. Turns out it didn't solve my
problem though. So, imagine we have a method (with a new generic).
Say,

setGeneric("glue",function(a,b) standardGeneric("glue"))
setMethod("glue",signature("character","character"),function(a,b) {
	paste(a,b,sep="")
})

Trying the code:
[1] "AB"
Error: object "B" not found
Error in glue("A", B) :
  error in evaluating the argument 'b' in selecting a method for function 'glue'

Good. Works as expected (there's no B in the environment). However,
I'd expect try to work...
Error: no function to return from, jumping to top level
Error in glue("A", B) :
  error in evaluating the argument 'b' in selecting a method for function 'glue'

with silent=TRUE the "jumping to top level" is not caught and causes
scripts to bail out.

Hopefully that helps?