From simon.urbanek at r-project.org  Tue Nov 13 15:52:37 2007
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 13 Nov 2007 09:52:37 -0500
Subject: [Rd] How to overload the assignment operator?
In-Reply-To: <20071113141905.267830@gmx.net>
References: <20071113141905.267830@gmx.net>
Message-ID: <3AE74023-B7C7-4E36-A2E5-FC407D666A48@r-project.org>


On Nov 13, 2007, at 9:19 AM, 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!?
>

You cannot use S3 here, because you want to dispatch on the *second*  
argument.

I don't think you want to do what you described - you would slow down  
everything in R considerably just by making `<-` a generic (and in  
fact you cannot do that for a good reason).

Why don't you take the external pointer approach that many others take  
to provide proxy objects to external data? (DB access, mem-mapped  
files, cross-language objects, etc.) That allows you to define your  
storage semantics very efficiently in C. You can still choose to  
define any syntactic sugar you want in either S3 or S4.

Cheers,
Simon



[Rd] How to overload the assignment operator?
Simon Urbanek