On Sat, 2 Jun 2007, Tim Keitt wrote:

> On 6/2/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
>> On Sat, 2 Jun 2007, Tim Keitt wrote:

[...]

>> > Edzer's approach is one I've suggested on many occasions -- that we
>> > subclass the sp classes to act as a proxy to a PostGIS table. I first
>> > developed that approach in rpgsql -- you could create proxy data
>> > frames that simply forwarded access requests to PostgreSQL (I think
>> > the idea has now been applied to SQLite tables). The problem of course
>> > is that R does not support polymorphism "below the surface" in the C
>> > level implementation, so once a proxy object is passed to R's
>> > internals, it is nothing more than a pointer with no call interface.
>> 
>> I really don't think that is true, and indeed polymorphism is almost
>> entirely implemented at C level.  A visible R object and a SEXP are one
>> and the same thing.
>
> I guess what I mean is that -- unless I'm mistaken -- I cannot
> override the data access routines. Lets say I have a C function that
> takes an SEXP as an argument and the function expects that SEXP to
> point to a data frame. I cannot call the same C function on an SEXP
> that points to a PostgreSQL proxy object because the C code will try
> to dereference memory offset from the base of the data portion of the
> SEXP. In the case of the db handle, there is no data in memory! Or is
> there now a full C-level function call interface for manipulating data
> frames (that can handle type dependent dispatch)? Cool if so -- its
> been awhile since I looked.
>
> (Just as an example think about what happens when the data in a matrix
> is passed to BLAS routines and what would happen if you tried to pass
> the db handle to BLAS.)

But that is several layers deeper. In general one should check that your 
code points to the type of object you want, and dispatch if you want to be 
polymorphic.  Remember that in S/R it is functions (including operators) 
that are polymorphic, and for example the C-level versions of [, $, $<- 
... all are (and long have been).

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to