From oehl_list at gmx.de  Tue Nov 13 16:57:03 2007
From: oehl_list at gmx.de (=?iso-8859-1?Q?=22Jens_Oehlschl=E4gel=22?=)
Date: Tue, 13 Nov 2007 16:57:03 +0100
Subject: [Rd] How to overload the assignment operator?
Message-ID: <20071113155703.57610@gmx.net>

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



[Rd] How to overload the assignment operator?
=?iso-8859-1?Q?=22Jens_Oehlschl=E4gel=22?=