From maechler at stat.math.ethz.ch  Mon Jan 14 19:39:10 2013
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 14 Jan 2013 19:39:10 +0100
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: <20724.20686.556286.756858@stat.math.ethz.ch>

>>>>> Fran?ois Michonneau <francois.michonneau at gmail.com>
>>>>>     on Sun, 13 Jan 2013 18:34:36 -0500 writes:

    > 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).

Well, the above is not reproducible
{foo  and  checkPhylo4   are missing !}.

If I make it reproducible,
it does work, i.e., give an error for me (rev 61644):

phylo4 <- 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,
                                        dimnames = list(NULL,
                                        c("ancestor", "descendant"))),
                          edge.length = numeric(0),
                          label = character(0),
                          edge.label = character(0),
                          order = "unknown",
                          annote = list()
         )
         )##               ),
         ## validity = checkPhylo4)

foo <- phylo4()
phylo4(foo, annote="bar")

-----------

Gives

Error in validObject(.Object) : 
  invalid class "phylo4" object: invalid object for slot "annote" in class "phylo4": got class "character", should be or extend class "list"

as it should.

Can you try providing a simple reproducible example?


>   What is now the preferred way of checking that annote is a actually a
> list?

>   Thanks,
>   -- Fran?ois

> 	[[alternative HTML version deleted]]



[Rd] Regarding the recent changes to @<-
Martin Maechler