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

From: Jens Oehlschlägel <>
Date: Tue, 13 Nov 2007 16:57:03 +0100

Thank you Brian,

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

So I understand that setReplaceMethod will not help.

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

I would be even happier if the cloning would only occur on any attempt to change the external pointer / proxy-object.

> There is no provision for that to depend on the class (rather than the
> type) of the object.

Mh, unless the internal copying mechanism would call a clone generic for non-atomic objects

> Since external pointers are never duplicated, you
> ought to be able to take advantage of that to design the copying semantics
> you want.

How that? How do I know that any user has assigned/modified the external pointer (or a proxy object containing the external pointer) such that I can invoke the cloning?

Best regards

Jens Oehlschlägel


______________________________________________ mailing list
Received on Tue 13 Nov 2007 - 16:07:42 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 - 23:30:18 GMT.

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