From daattali at gmail.com  Tue Jun 30 09:02:34 2015
From: daattali at gmail.com (Dean Attali)
Date: Tue, 30 Jun 2015 00:02:34 -0700
Subject: [Rd] Defining a `show` function breaks the print-ing of S4 object
 -- bug or expected?
Message-ID: <CA+j8Z+=233OjOe00qV+5MdF9kkkVrWh4wfmUeAzwb4Q12DSxew@mail.gmail.com>

Hi r-devel

If you define a function named `show` or attach a package with an exported
`show` function, then printing/vieweing S4 objects breaks. This is probably
because the `print` function calls `show`, which is now masked.

Example:

show <- function() {}
> setClass("Person", slots = list(name = "character"))
> tom <- new("Person", name = "Tom")
> tom # error
> methods::show(tom) # works


The error was a surprise to me because  I was under the assumption that
`show` would be namespaced and therefore should not break.
I'm wondering if this is intended behaviour, or if this is a problem.  My
intuition, and Hadley agreed on Twitter, is that defining a `show` method
should not have such a grave effect on printing S4 objects.

Thanks

---
http://deanattali.com

	[[alternative HTML version deleted]]



[Rd] Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
Dean Attali