From sfalcon at fhcrc.org  Tue May 22 02:15:10 2007
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Mon, 21 May 2007 17:15:10 -0700
Subject: [Rd] relist, an inverse operator to unlist
In-Reply-To: <20070519160413.GK21178@econ.upenn.edu> (Andrew Clausen's message
	of "Sat, 19 May 2007 12:04:13 -0400")
References: <20070513172911.GP6923@econ.upenn.edu>
	<971536df0705131602p2e407fa2sd1d5e6984d2ffa56@mail.gmail.com>
	<20070514043240.GL28199@econ.upenn.edu>
	<971536df0705132354u6e2ae0cci9b1e42a766dc0ec5@mail.gmail.com>
	<17992.5499.383704.358418@stat.math.ethz.ch>
	<20070519153636.GJ21178@econ.upenn.edu>
	<20070519160413.GK21178@econ.upenn.edu>
Message-ID: <m2r6p990j5.fsf@ziti.local>

Hi Andrew,

Andrew Clausen <clausen at econ.upenn.edu> writes:
> For reasons I can't explain, the code I posted worked in my session, but didn't
> work when I started a fresh one.  standardGeneric() seems to get confused
> by defaults for missing arguments.  It looks for a "missing" method with
> this code:
>
> 	relist <- function(flesh, skeleton=attr(flesh, "skeleton"))
> 	{
> 		standardGeneric("relist")
> 	}

This looks very odd to me.  If you are creating an S4 generic
function, why are you not calling setGeneric?  Or has that part of the
code simply been omitted from your post?

I will also add that the notion of a default argument on a generic
function seems a bit odd to me.  If an argument is available for
dispatch, I just don't see what sense it makes to have a default.  In
those cases, the default should be handled by the method that has a
signature with said argument matching the "missing" class.

What often does make sense is to define a generic function where some
argument are not available for dispatch.  For example:

setGeneric("foo", signature="flesh",
           function(flesh, skeleton=attr(flesh, "skeleton") 
               standardGeneric("foo")))


+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org



[Rd] relist, an inverse operator to unlist
Seth Falcon