From ripley at stats.ox.ac.uk  Wed Nov 14 09:09:16 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 14 Nov 2007 08:09:16 +0000 (GMT)
Subject: [Rd] slots of type "double"
In-Reply-To: <Pine.LNX.4.64.0711131816130.11720@gannet.stats.ox.ac.uk>
References: <1194942985.4739620919f16@webmail.fhcrc.org>
	<2BBF01A3-5F39-4750-B42E-12605674F49E@r-project.org>
	<Pine.LNX.4.64.0711131448370.9317@gannet.stats.ox.ac.uk>
	<4739E8F3.5040302@r-project.org>
	<Pine.LNX.4.64.0711131816130.11720@gannet.stats.ox.ac.uk>
Message-ID: <Pine.LNX.4.64.0711140746220.11794@gannet.stats.ox.ac.uk>

On Tue, 13 Nov 2007, Prof Brian Ripley wrote:

> On Tue, 13 Nov 2007, John Chambers wrote:
>
>> What's the proposal here?  To eliminate "double" as a class?  No objection
>
> Eliminate "double" and "single".
>
>> from this corner.  As I remember, it was put in early in the 
>> implementation of methods, when I was confused about what R intended in 
>> this area (well, I'm not totally unconfused even now).
>> 
>> If this is the proposal, we could implement it in r-devel and see if 
>> there are complaints.
>
> I was going to propose so after running some tests over CRAN/BioC (which 
> will take a few hours).

Which showed up problems in packages Matrix and matlab.

Matrix clearly has a different view of these classes:

## "atomic vectors" (-> ?is.atomic ) --
## ---------------  those that we want to convert from old-style "matrix"
setClassUnion("atomicVector", ## numeric = {integer, double} but all 3 
should *directly* be atomic
               members = c("logical", "integer", "double", "numeric",
                           "complex", "raw", "character"))

If I remove "double" there, I get an error in an example:

> stopifnot(is(scm, "sparseVector"),
+           identical(cm, as.numeric(scm)))
Error in as(x at x, mode) :
   no method or default for coercing "numeric" to "double"

and looking at the code suggests that "double" is used as the class name 
in several places.


Package matlab is simpler: test mkconstarray.R fails at

   > test.mkconstarray(list(class.type = "double", value = pi, size = 4), 
rep(pi, 4))
   Error in as(value, match.arg(class.type)) :
     no method or default for coercing "numeric" to "double"

and needs the author to rectify his confusion between "class" and "type".

I'd like to give the Matrix authors a chance to look into this before 
making the change.  Loking at the packages has reinforced my impression 
that having "double" as an S4 class is only adding confusion, so the 
change is desirable.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] slots of type "double"
Prof Brian Ripley