From jmc at R-project.org  Tue Nov 22 21:08:54 2005
From: jmc at R-project.org (John Chambers)
Date: Tue, 22 Nov 2005 15:08:54 -0500
Subject: [Rd] failure in `setClass' examples
In-Reply-To: <87psosfqet.fsf@gmail.com>
References: <87psosfqet.fsf@gmail.com>
Message-ID: <43837AD6.4020300@R-project.org>

There's nothing bad happening, and we should remove the setIs() example 
from the setClass() documentation.

If you run example(setIs), you will see a slightly different version of 
the same call to setIs(), but one that does not generate the warning 
(because it includes the argument replace= to setIs()). Comparing the 
two calls and looking at the documentation for setIs should explain 
where the warning comes from.  But in any case, nothing to worry about.

John Chambers.

Sebastian Luque wrote:
> Hello,
> 
> Below is what I got running the examples from `setClass'.  Could somebody
> please help explain why the last `setIs' call is returning the warning and
> whether this is expected?
> 
> 
> R>      setClass("track",
> +               representation(x="numeric", y="numeric"))
> [1] "track"
> R>      setClass("trackCurve",
> +               representation("track", smooth = "numeric"))
> [1] "trackCurve"
> R>      setClass("trackMultiCurve",
> +               representation(x="numeric", y="matrix", smooth="matrix"),
> +               prototype = list(x=numeric(), y=matrix(0,0,0),
> +                                smooth= matrix(0,0,0)))
> [1] "trackMultiCurve"
> R>      try(setIs("trackMultiCurve", "trackCurve",
> +          test = function(obj) {ncol(slot(obj, "y")) == 1}))
> Warning message:
> there is no automatic definition for as(object, "trackCurve") <- value when object has class "trackMultiCurve" and no 'replace' argument was supplied; replacement will be an error in: makeExtends(class1, class2, coerce, test, replace, by, classDef1 = classDef,  
> R>      setIs("trackMultiCurve", "trackCurve",
> +        test = function(obj) {ncol(slot(obj, "y")) == 1},
> +        coerce = function(obj) {
> +           new("trackCurve",
> +               x = slot(obj, "x"),
> +               y = as.numeric(slot(obj,"y")),
> +               smooth = as.numeric(slot(obj, "smooth")))
> +        })
> Warning message:
> there is no automatic definition for as(object, "trackCurve") <- value when object has class "trackMultiCurve" and no 'replace' argument was supplied; replacement will be an error in: makeExtends(class1, class2, coerce, test, replace, by, classDef1 = classDef,  
> R> version
>          _                
> platform i486-pc-linux-gnu
> arch     i486             
> os       linux-gnu        
> system   i486, linux-gnu  
> status                    
> major    2                
> minor    2.0              
> year     2005             
> month    10               
> day      06               
> svn rev  35749            
> language R                
> 
> 
> Thanks in advance,
>



[Rd] failure in `setClass' examples
John Chambers