Re: [Rd] Fwd: Digest package - make digest generic?

From: Roger Peng <rdpeng_at_gmail.com>
Date: Tue, 16 Oct 2007 16:59:59 -0400

Calling 'digest.default' directly would not be possible if the method were hidden in a namespace (without resorting to some maneuvering). To force the default method I think you'd need to 'unclass' the object.

I'm not against making 'digest' generic, but I'd prefer it if there were a guaranteed way to compute the digest of the "raw"/full object without having to wonder about class-specific behavior. Something like:

digest0 <- [[the current 'digest' function]] digest <- function(object, ...) UseMethod("digest") digest.default <- function(object, ...) digest0(object, ...)

As I think we've seen in this discussion already, what is surprising to one person may not be surprising to another (and vice versa) so having something like 'digest0' which is consistent across all R objects would be useful.

-roger

On 10/16/07, hadley wickham <h.wickham_at_gmail.com> wrote:
> On 10/16/07, Roger Peng <rdpeng@gmail.com> wrote:
> > My understanding was that Hadley wanted 'digest' to operate on part of
> > an object rather than on the entire, which might contain uninteresting
> > or irrelevant details. For example, if we had
> >
> > a <- structure(list(x = 1, y = 2), class = "foo")
> > b <- structure(list(x = 2342342, y = 2), class = "foo")
> >
> > digest.foo <- function(object, ...) digest(object$y)
>
> Yes, that's exactly what I want, except in my case my objects contain
> about 20 or 30 bits of information that are irrelevant (I'm my case
> documentation about the class and other functions), so it would be
> surprising if p1 and p2 which produced identical plots gave different
> digests.
>
> If you want the default behaviour, you could always call
> digest.default to digest the entire object.
>
> Hadley
>

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 16 Oct 2007 - 21:03:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 25 Oct 2007 - 11:37:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.