Looks good. I think using S4 inheritance for S3 dispatch is a relatively
new feature. Should we do this for all S3 generics?

Michael


On Thu, Oct 25, 2012 at 12:34 PM, Martin Morgan <mtmorgan@fhcrc.org> wrote:

> On 10/25/2012 07:53 PM, Cook, Malcolm wrote:
>
>> Namely, base::Reduce coerces X to a list using as.list  if it is an object
>> whereas BiocGenerics::Reduce does not.  Otherwise they are identical.
>>
>> As a result, base::Reduce(myGRangesList) fails with "no method for
>> coercing
>> this S4 class to a vector".
>>
>
> Well, so when you put it this way... I was wondering why there is no
>
>   as.list.List
>
> i.e., an S3 method for List on the generic as.list? This seems to be
> consistent with the recommendation on ?Methods under 'Methods for S3
> Generic Functions' (and this little hack seems to allow both Reduce and
> mclapply to 'work').
>
> Index: NAMESPACE
> ==============================**==============================**=======
> --- NAMESPACE   (revision 70700)
> +++ NAMESPACE   (working copy)
> @@ -332,3 +332,4 @@
>      expand
>  )
>
> +S3method(as.list, List)
> Index: R/List-class.R
> ==============================**==============================**=======
> --- R/List-class.R      (revision 70700)
> +++ R/List-class.R      (working copy)
> @@ -442,10 +442,11 @@
>  ### Coercion.
>  ###
>
> +as.list.List <-
> +    function(x, ...) lapply(x, identity)
> +
>  setAs("List", "list", function(from) as.list(from))
>
> -setMethod("as.list", "List", function(x, ...) lapply(x, identity))
> -
>  setGeneric("as.env", function(x, ...) standardGeneric("as.env"))
>
>  setMethod("as.env", "List",
>
> --
> Computational Biology / Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N.
> PO Box 19024 Seattle, WA 98109
>
> Location: Arnold Building M1 B861
> Phone: (206) 667-2793
>
> ______________________________**_________________
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/bioc-devel<https://stat.ethz.ch/mailman/listinfo/bioc-devel>
>

	[[alternative HTML version deleted]]

