From jmc at r-project.org  Mon Jan 14 18:54:27 2013
From: jmc at r-project.org (John Chambers)
Date: Mon, 14 Jan 2013 09:54:27 -0800
Subject: [Rd] Regarding the recent changes to @<-
In-Reply-To: <CAKL30wVySBksnfovg6TxAk9tmHzu_bSc=tip7rDS4iDnA1_mbQ@mail.gmail.com>
References: <CAKL30wVySBksnfovg6TxAk9tmHzu_bSc=tip7rDS4iDnA1_mbQ@mail.gmail.com>
Message-ID: <BD5840E9-B37B-4ACC-B61F-60C45712EFF4@r-project.org>

Thanks.  No need for a complicated example actually:

> C1 <- setClass("C1", slots = c(x = "numeric"))
> c1 <- C1()
> c1 at x <- "Hello"
> validObject(c1)
Error in validObject(c1) : 
  invalid class "C1" object: invalid object for slot "x" in class "C1": got class "character", should be or extend class "numeric"

In making @<- substantially more efficient in r-devel, we lost some error checking.  That's too efficient.

This will be fixed, but given that code has migrated from an R function to C and that I'm not currently at home, it may take a little while.

John


On Jan 13, 2013, at 3:34 PM, Fran?ois Michonneau wrote:

> Hello all,
> 
>  In one of the packages (phylobase) I'm contributing to, we define a class
> as follows:
> 
> setClass("phylo4",
>         representation(edge = "matrix",
>                        edge.length = "numeric",
>                        label = "character",
>                        edge.label = "character",
>                        order = "character",
>                        annote = "list"),
>         prototype = list(
>                        edge = matrix(nrow = 0, ncol = 2,
>                            dimname = list(NULL, c("ancestor",
> "descendant"))),
>                        edge.length = numeric(0),
>                        label = character(0),
>                        edge.label = character(0),
>                        order = "unknown",
>                        annote = list()
>                       ),
>         validity = checkPhylo4)
> 
>  Using today's SVN checkout (r61643), building an object of the class
> 'phylo4' like this:
> 
> phylo4(foo, annote="bar")
> 
>  doesn't return an error as it used to (given that annote is not a list).
> 
>  What is now the preferred way of checking that annote is a actually a
> list?
> 
>  Thanks,
>  -- Fran?ois
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Regarding the recent changes to @<-
John Chambers