From luke-tierney at uiowa.edu  Tue Jun 30 17:11:10 2015
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Tue, 30 Jun 2015 10:11:10 -0500
Subject: [Rd] Defining a `show` function breaks the print-ing of S4
 object -- bug or expected?
In-Reply-To: <CABdHhvG7XJS6td4CxYYPBjgtwXqShGcRuDHvJ=HaKPT7jdb6VA@mail.gmail.com>
References: <CA+j8Z+=233OjOe00qV+5MdF9kkkVrWh4wfmUeAzwb4Q12DSxew@mail.gmail.com>
	<CABdHhvEVbdbNKUswtqENgfy1L4yQDOEEKyO--ft+x7f2M+ALPg@mail.gmail.com>
	<5592898B.5000103@gmail.com>
	<CABdHhvG7XJS6td4CxYYPBjgtwXqShGcRuDHvJ=HaKPT7jdb6VA@mail.gmail.com>
Message-ID: <alpine.OSX.2.02.1506301009280.7711@lukes-macbook-air.local>

Same thing happens with S3 if you redefine print(). I thought that
code was actually calculating the function to call rather than the
symbol to use, but apparently not. Shouldn't be too hard to fix.

luke

On Tue, 30 Jun 2015, Hadley Wickham wrote:

> 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
>
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
luke-tierney at uiowa.edu