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

2012-10-23 Thread North, Ben
Hi Romain, > > Because `$` doesn't evaluate its field-name argument, is > > > > field.name <- "value" > > do.call(`$`, list(x, field.name)) > > > > the recommended way of accessing methods whose names are computed at > > run-time? It does work; just wondering if there's a better way. >

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

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

[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