Hi,

In an effort to learn S4 objects, I am trying to port some  c based tree
code to S4 object.  My immediate goal is to use .Call() interface for
calling my c code from R. My long term goal is to understand how to write c
structs that follows S4 classes and not the other-way-around.

The c struct for the node is :
typedef struct node{
  int c;
  int n;
  inode **nodes;  //length  = n
} inode;

I am trying to define corresponding S4 class. The closest I could come was:
setClassUnion("listOrNULL",members=c("list", "NULL"))
setClass(Class = "Inode", representation(c =
"numeric",n="numeric",nodes="listOrNULL"))

This does not work, as setting an element of the list of nodes in a node
object overwrites the original object. I have read that there are dirty ways
of writing code that gets around this issue. For example, using the assign()
operator.
I am not even sure if it will work.

I would appreciate if someone suggest ways in which this problem is best
approached.
Is it possible to have recursive data-structures within R ?
What is the best way of writing an interface with pre-existing c code?
What are the best practices for deveolping new code in c for such purposes?

Thanks,

Russ

	[[alternative HTML version deleted]]

