Skip to content

[Rcpp-devel] Internals: how does DataFrame get initialized?

2 messages · Darren Cook, Davor Cubranic

#
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.

Darren

[1]:
https://r-forge.r-project.org/scm/viewvc.php/pkg/Rcpp/inst/include/Rcpp/RObject.h?view=markup&root=rcpp

[2]:
https://r-forge.r-project.org/scm/viewvc.php/pkg/Rcpp/inst/include/Rcpp/DottedPair.h?view=markup&root=rcpp

[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 :-)
4 days later
#
On 2012-02-29, at 5:00 PM, Darren Cook wrote:

            
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.
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