[Rcpp-devel] Odd-seeming behaviour of [[ and $

2012-10-22 Thread North, Ben
Hi, I recently came across some behaviour of `[[` and `$` which surprised me. I was trying to access a method of a class implemented using Rcpp, choosing the method name at runtime, but the example below uses a fixed method name to keep it short. The full C++ code: - - - - 8< - - - - #include

Re: [Rcpp-devel] Odd-seeming behaviour of [[ and $

2012-10-22 Thread Romain Francois
Hello, This is an implementation artefact. In short, you are not supposed to use [[. Romain Le 22/10/12 10:54, North, Ben a écrit : Hi, I recently came across some behaviour of `[[` and `$` which surprised me. I was trying to access a method of a class implemented using Rcpp, choosing the

Re: [Rcpp-devel] Odd-seeming behaviour of [[ and $

2012-10-22 Thread North, Ben
Hi Romain, Thanks for the reply. > > The fact that 'x[["value"]]' finds the method only if I've first done > > 'x$value' seemed odd. > > This is an implementation artefact. In short, you are not supposed to > use [[. OK, fair enough :) Because `$` doesn't evaluate its field-name argument, is