I'd like to suggest that whenever there is no S3 method implementation
available for a particular class, that the error message would also
report the class structure of the object dispatched on.

Example:

foo <- function(...) UseMethod("foo")
foo.ClassA <- function(object, ...) { cat("foo() for ClassA called.\n") }

> foo(structure(1, class="ClassA"))
foo() for ClassA called.

Now:

> foo(NULL)
Error in UseMethod("foo") : no applicable method for "foo"

> foo(Sys.time())
Error in UseMethod("foo") : no applicable method for "foo"

Suggestion:

> foo(NULL)
Error in UseMethod("foo") : no applicable foo() method: list

> foo(Sys.time())
Error in UseMethod("foo") : no applicable foo() method: POSIXt, POSIXct

This would really help troubleshooting, especially when running in
batch mode where you don't have direct access to the object without
modifying the script and/or functions.

/Henrik

PS. I know that one as a workaround can create a "default" method that
reports this, but I believe it is much better that the builtin
exception handling should report this/carry this information.

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to