Skip to content
Prev 26414 / 63424 Next

Digest package - make digest generic?

Sorry, I forgot the 'reply-all'.

-roger

---------- Forwarded message ----------
From: Roger Peng <rdpeng at gmail.com>
Date: Oct 16, 2007 8:24 AM
Subject: Re: [Rd] Digest package - make digest generic?
To: Henrik Bengtsson <hb at stat.berkeley.edu>


Would it be possible to instead create a function with a name like
'digest0' which is the current function, and then create a generic
function with the name 'digest'?  In this case 'digest0' always
returns the digest of the "raw" object.

My one concern is that my current expectation is that 'digest' takes
an object and hashes the entire object, regardless of class.  So if
two objects are different (even in their internal representation),
they should return different digests.  I would be a little worried if
'digest' had a different (and perhaps unpredictable) behavior
depending on the class of the object where two objects that were in
fact different could lead to the same digest.

I can see why one might want class-specific behavior, but what a class
author wants from 'digest' may not be different from what other users
of 'digest' on that object want.

A simple approach might be

digest0 <- function(x, ...) digest(unclass(x), ...)

although this doesn't work for S4 objects I don't think.

-roger
On 10/15/07, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
--
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/