On 2012-02-29, at 5:00 PM, Darren Cook wrote:

> Thanks for the reply Davor. It was a design question: why does
> DottedPair [2] have its own class? It does not add any member variables
> and it does not override any functions in its base class [1], so I
> assume it exists solely for code clarity [3]. I wondered what concept is
> was clarifying or representing.

I should let Romain and Dirk speak about their design choices here, but I think 
it will make more sense if you consider that both classes have a close 
relationship with R's SEXP union. So the pairlist "class" (i.e., the member of 
the C union) that is proxied by the DottedPair adds its own member variables 
(the CAR and CDR of the pair), and from the point of view of the consumer of 
the Rcpp API (you), it's as if those were internal to the DottedPair class, and 
not shared with any other subtype of the Robject hierarchy.

> [3]: Another way of saying that is that it seems I could move all
> DottedPair's functions into Robject, then write:
> 
>  class DottedPair: public Robject {}
> 
> and everything should still compile and work. (Or I've misunderstood
> something :-)

So this would have all of DottedPair's methods in Robject? What happens when 
you assign a non-pairlist SEXP (say, a vector) to an instance of Robject and 
then invoke one of the DottedPair's methods on it?

Davor
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to