From maechler at stat.math.ethz.ch  Thu Sep 21 09:41:32 2006
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Thu, 21 Sep 2006 09:41:32 +0200
Subject: [Rd] S4 generics, modify() generic and modifyList() ...
In-Reply-To: <eb555e660609191348u1310c80r414ab2f0cb4b9fa8@mail.gmail.com>
References: <eb555e660609151222u2f1a7856l6b5f786c8677966@mail.gmail.com>
	<17675.2988.727158.326024@stat.math.ethz.ch>
	<eb555e660609151354t22c68166s4b0144a286c68f50@mail.gmail.com>
	<eb555e660609181500t4f823763t8bdae712333a8e0@mail.gmail.com>
	<971536df0609191311u1dc45bd4w9730b00349826b1@mail.gmail.com>
	<eb555e660609191348u1310c80r414ab2f0cb4b9fa8@mail.gmail.com>
Message-ID: <17682.16940.985939.341850@stat.math.ethz.ch>

>>>>> "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




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