From geoffjentry at hexdump.org  Tue May  3 20:55:47 2011
From: geoffjentry at hexdump.org (Geoff Jentry)
Date: Tue, 3 May 2011 11:55:47 -0700 (PDT)
Subject: [Rd] Reference Classes: Accessing methods via [[...]], bug?
In-Reply-To: <4DBDE093.5080300@fhcrc.org>
References: <SNT131-w42BCCDD218A68509A634CFB99D0@phx.gbl>
	<BANLkTi=GvhhFmDT1=8sf0j6cM8Tsx3QJ9Q@mail.gmail.com>
	<4DBDDA21.3020809@r-project.org> <4DBDE093.5080300@fhcrc.org>
Message-ID: <Pine.LNX.4.64.1105031153350.3175@cardinals.dreamhost.com>

On Sun, 1 May 2011, Martin Morgan wrote:
> On 05/01/2011 03:09 PM, John Chambers wrote:
>> It would be interesting to get some experience and opinions on whether
>> this is a good idea or not. It breaks encapsulation, in that the
>> behavior of the class can no longer be inferred from the class
>> definition alone. On the other hand, it is convenient and relates to
>> "operator overloading" in some other languages.
> I have written 'show' methods for reference classes (is there another way to 
> pretty-print them?) and S4 methods that dispatch to reference methods (in 
> particular, yield(x) on connection-like classes dispatching to x$yield()).

Most of my S4 method usage with reference classes has been the 'show' 
methods for the same reason that Martin states - I was unable to find 
another mechanism of pretty printing, and wanted something along those 
lines for situations such as a list of objects and how that gets rendered 
on the screen.

I've also made use of S4 methods for reference classes to help maintain 
backwards compatibility for cases where I've changed the underlying 
implementation from S4 to using reference classes - in those cases the 
ability to use S4 methods was handy but not strictly necessary.



[Rd] Reference Classes: Accessing methods via [[...]], bug?
Geoff Jentry