From h.wickham at gmail.com  Tue Jun 30 14:38:15 2015
From: h.wickham at gmail.com (Hadley Wickham)
Date: Tue, 30 Jun 2015 14:38:15 +0200
Subject: [Rd] Defining a `show` function breaks the print-ing of S4
 object -- bug or expected?
In-Reply-To: <5592898B.5000103@gmail.com>
References: <CA+j8Z+=233OjOe00qV+5MdF9kkkVrWh4wfmUeAzwb4Q12DSxew@mail.gmail.com>
	<CABdHhvEVbdbNKUswtqENgfy1L4yQDOEEKyO--ft+x7f2M+ALPg@mail.gmail.com>
	<5592898B.5000103@gmail.com>
Message-ID: <CABdHhvG7XJS6td4CxYYPBjgtwXqShGcRuDHvJ=HaKPT7jdb6VA@mail.gmail.com>

On Tue, Jun 30, 2015 at 2:20 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 30/06/2015 1:57 PM, Hadley Wickham wrote:
>> A slightly simpler formulation of the problem is:
>>
>> show <- function(...) stop("My show!")
>> methods::setClass("Person", slots = list(name = "character"))
>> methods::new("Person", name = "Tom")
>> #> Error in (function (...)  : My show!
>
> Just to be clear:  the complaint is that the auto-called show() is not
> methods::show?  I.e. after
>
> x <- methods::new("Person", name = "Tom")
>
> you would expect
>
> show(x)
>
> to give the error, but not
>
> x
>
> ??

Correct - I'd expect print() to always call methods::show(), not
whatever show() is first on the search path.

Hadley

-- 
http://had.co.nz/



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