[R-sig-Geo] C API for sp classes?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Mar 7 18:39:59 CET 2006


Tim Keitt wrote:

> That's a rather odd aspect of S methods 

  one of many :)

>-- even if you only want to call
> the function for a single class, you have to create a generic function.
> In cases where I'm not wanting polymorphic behavior (the function really
> only makes sense for a single class), I tend to write ordinary functions
> and either test for class membership or just document that the passed
> object should be of the appropriate class. When the function will be
> called on multiple classes, then it is worth defining a generic
> function. Making everything generic is too much overhead.

  I think this stems from the S3 way that what other languages call 
"methods of objects", R has as global namespace functions. In Python for 
example, the method name is tied to the object, so you do: foo.bar() 
instead of bar(foo). S3 shoe-horned the OO paradigm into the existing 
functional syntax instead of extending the syntax such that methods were 
true properties of objects. S4 methods continue this (IMHO) poor design 
choice, and then tries to tidy up by having 'namespaces' declared in 
packages - but at least it has a more formal method for declaring 
methods instead of S3's reliance on <generic>.<class> naming scheme!

  If I could transparently bind all the statistical and graphical 
functionality of R with the Python language I'd be happy :)[1]

Barry

[1] Yeah, I know there are R-Python links but they're not quite 
transparent enough....




More information about the R-sig-Geo mailing list