Skip to content
Prev 26673 / 63424 Next

How to overload the assignment operator?

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

            
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.