From tshort.rlists at gmail.com  Mon Apr 13 13:42:28 2009
From: tshort.rlists at gmail.com (Tom Short)
Date: Mon, 13 Apr 2009 07:42:28 -0400
Subject: [Rd] Simple class with an automatic printing issue
In-Reply-To: <77EB52C6DD32BA4D87471DCD70C8D7000107590F@NA-PA-VBE03.na.tibco.com>
References: <fd27013a0904121559hc3ccb30n83272819ca8f714a@mail.gmail.com>
	<77EB52C6DD32BA4D87471DCD70C8D7000107590F@NA-PA-VBE03.na.tibco.com>
Message-ID: <fd27013a0904130442t2c6e7ad4r21b5e6c19ec0ed9f@mail.gmail.com>

Thanks, Bill. Searching R-devel based on your input shows that this is
a known issue as pointed out by Martin Maechler:

https://stat.ethz.ch/pipermail/r-devel/2008-October/051109.html

- Tom



On Sun, Apr 12, 2009 at 11:34 PM, William Dunlap <wdunlap at tibco.com> wrote:
>
> It may have to do with the results of is.object():
>
> ?> is.object(1*structure(1,class="testClass"))
> ?[1] FALSE
> ?> is.object(structure(1,class="testClass")*1)
> ?[1] TRUE
> ?> is.object(structure(1,class="testClass"))
> ?[1] TRUE
>
> is.object(x) should be true if x has a class attribute,
> but 1*structute(1,class="testClass") makes a thing
> with a class attribute but without the 'OBJECT' bit set.
>
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
>
> > -----Original Message-----
> > From: r-devel-bounces at r-project.org
> > [mailto:r-devel-bounces at r-project.org] On Behalf Of Tom Short
> > Sent: Sunday, April 12, 2009 4:00 PM
> > To: r-devel at r-project.org
> > Subject: [Rd] Simple class with an automatic printing issue
> >
> > I don't understand the following behavior for a simple S3 class. The
> > auto-printing at the command line
> > doesn't behave as I expect. I'm probably missing something,
> > but it might be
> > a bug.
> >
> > > print.testClass <- function(x, ...) cat("Class:", class(x),
> > ":", x, "\n")
> >
> > > structure(1, class = "testClass")
> > Class: testClass : 1
> >
> > > print(1 * structure(1, class = "testClass"))
> > Class: testClass : 1
> >
> > > 1 * structure(1, class = "testClass") # why doesn't
> > auto-printing call
> > print.testClass here?
> > [1] 1
> > attr(,"class")
> > [1] "testClass"
> >
> > > structure(1, class = "testClass") * 1
> > Class: testClass : 1
> >
> >
> > platform ? ? ? i386-pc-mingw32
> > arch ? ? ? ? ? i386
> > os ? ? ? ? ? ? mingw32
> > system ? ? ? ? i386, mingw32
> > status ? ? ? ? RC
> > major ? ? ? ? ?2
> > minor ? ? ? ? ?9.0
> > year ? ? ? ? ? 2009
> > month ? ? ? ? ?04
> > day ? ? ? ? ? ?10
> > svn rev ? ? ? ?48318
> > language ? ? ? R
> > version.string R version 2.9.0 RC (2009-04-10 r48318)
> >
> > ? ? ? [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >



[Rd] Simple class with an automatic printing issue
Tom Short