Re: [Rd] How to overload the assignment operator?

From: Prof Brian Ripley <>
Date: Tue, 13 Nov 2007 15:04:43 +0000 (GMT)

On Tue, 13 Nov 2007, "Jens Oehlschlägel" wrote:

> Thanks Matthias,
>> are you looking for "setReplaceMethod"?
> So far the package I m writing has avoided using anything from S4 and
> the implications of touching S4 are not clear to me. The package aims on
> providing an alternative to 'atomic' data stored in ram, i.e. large
> atomic data stored on disk. I need some advice how to do this maximally
> performant, which probably means pure S3!?

setReplaceMethod() is just syntactic sugar for setting an S4 method on a replacement function (read the function definition to see so). You can set S3 replacement methods, and the S4 mechanism just piggy-backs on that.

I think the conceptual problem is that the assignment operator does not actually do any copying: it creates a binding of a symbol to a value. Any copying which occurs happens when the value is (potentially) changed. There is no provision for that to depend on the class (rather than the type) of the object. Since external pointers are never duplicated, you ought to be able to take advantage of that to design the copying semantics you want.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list

Received on Tue 13 Nov 2007 - 15:08:29 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 Tue 13 Nov 2007 - 16:30:18 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.