From simon.urbanek at r-project.org  Tue Nov 13 15:23:53 2007
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 13 Nov 2007 09:23:53 -0500
Subject: [Rd] slots of type "double"
In-Reply-To: <1194942985.4739620919f16@webmail.fhcrc.org>
References: <1194942985.4739620919f16@webmail.fhcrc.org>
Message-ID: <2BBF01A3-5F39-4750-B42E-12605674F49E@r-project.org>


On Nov 13, 2007, at 3:36 AM, hpages at fhcrc.org wrote:

> Any idea why S4 doesn't allow slots of type "double"?
>

Type (as in storage type and "double" is a storage type) has nothing  
to do with classes. You cannot create slots for types, only for classes.


>> setClass("A", representation(a="double"))
>  Error in makePrototypeFromClassDef(properties, ClassDef, immediate,  
> where) :
>    in making the prototype for class "A" elements of the prototype  
> failed to
> match the corresponding slot class: a (class ?double? )
>
> "numeric", "integer", "character", "complex", "raw", etc... they all  
> work but "double" doesn't. Any reason for this strange exception?
>

AFAICS there is no way to create an object of the class "double" (save  
for 'faking' it by creating an informal S3 object), so such definition  
is useless. And given this fact, even the internal code is unable to  
create it, so it doesn't match the signature. Note:

 > a=new("double")
 > class(a)
[1] "numeric"
 > is(a,"double")
[1] FALSE

I think it comes from the fact that there is an S4 definition for the  
class "double" which is not valid. That is probably a bug and the  
class definition should be removed.

Cheers,
Simon



[Rd] slots of type "double"
Simon Urbanek