[Rd] How to overload the assignment operator?
"Jens Oehlschlägel"
oehl_list at gmx.de
Tue Nov 13 16:57:03 CET 2007
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
--
More information about the R-devel
mailing list