[Rd] S4 generics, modify() generic and modifyList() ...

Martin Maechler maechler at stat.math.ethz.ch
Thu Sep 21 09:41:32 CEST 2006


>>>>> "DeepS" == Deepayan Sarkar <deepayan.sarkar at gmail.com>
>>>>>     on Tue, 19 Sep 2006 13:48:52 -0700 writes:

    DeepS> On 9/19/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
    >> Perhaps it should have another name, be made generic and extended
    >> to functions in which case it would work on the formal arguments.  e.g.
    >> 
    >> read.table.comma <- modify(read.table, list(sep = ","))
    >> 
    >> would return a function that is the same as read.table but
    >> has "," as the default for sep.
    >> 
    >> Python has something like this called partial:
    >> http://docs.python.org/dev/whatsnew/pep-309.html

    DeepS> I have had similar thoughts, and even requested a variant a while
    DeepS> back, with a possible implementation:

    DeepS> https://stat.ethz.ch/pipermail/r-devel/2006-March/036696.html

yes, indeed.

    DeepS> Again, the main question is whether it makes sense to introduce this
    DeepS> in `one of the base packages'.

for some reason I had hasted to port your  modifyList() not only
to R-devel, but also to R-alpha (now "beta").

[So now you, Deepayan, need to upgrade lattice before release in
 order to make the warning disappear].

For the mid to longer term I agree a modify() generic might be
nicer, and the method for "function" may even be more useful
than the one for list  [[and modifyList() would eventually be deprecated]].

OTOH, for new generics, I'd tend to argue we should be nice R-izens
and use S4 rather than S3.  For the time being that
would mean it had to go into the methods package.

Or is now {with the dramatic S4 improvements in 2.4.0} a good
time to start thinking about making "utils" depend on "methods"
or even "better" [ ;-) I know, not all agree here ]
think about a dependency tree
   base -> methods -> [everything else]  for the base packages ?
so we could merge 'stats4' into 'stats' ?

   [[yes, I'm now going into deap-sea position, not putting my head
     out to be shot easily ... ]

Martin




More information about the R-devel mailing list