[Rcpp-devel] Testing for existence of named components

R. Michael Weylandt michael.weylandt at gmail.com
Thu Mar 29 20:34:06 CEST 2012


On Thu, Mar 29, 2012 at 2:18 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 29 March 2012 at 18:51, Patrick Burns wrote:
> | On 29/03/2012 18:33, Dirk Eddelbuettel wrote:
> | >
> | > On 29 March 2012 at 19:12, Romain Francois wrote:
> | > | Le 28/03/12 13:56, Ulrich Bodenhofer a écrit :
> | > |>  Hi,
> | > |>
> | > |>  My question is the following: is there any way of checking in whether a
> | > |>  component of an Rcpp list (or vector) with a given name exists in this
> | > |>  list. If I simply try accessing a non-existing component, I get an
> | > |>  "index out of bounds" error. Trying to catch a possible exception did
> | > |>  not work either. I also browsed the Rcpp package source code, but
> | > |>  unfortunately I got lost. Sorry if this has been addressed on this list
> | > |>  before. At least I googled in many different ways, but could not find
> | > |>  anything. Any ideas? Any help is gratefully appreciated!
> | > |>
> | > |>  Thanks and best regards,
> | > |>  Ulrich
> | > |
> | > | Hello,
> | > |
> | > | I commited the has_element_called method on the Vector template (vectors
> | > | of all sorts, incl lists).
> | >
> | > +1, but how about just calling it 'contains' rather 'has_element_called' ?
> |
> | I think 'contains' would imply a value
> | in the vector rather than a name.  The
> | extra typing might be worth avoiding
> | that confusion.
>
> While that is true, it cannot deflect away from the fact that Hadley and I
> are in a deadly mano-a-mano battle about the extended use, or, in my case,
> strict avoidance, of underscores.  That is /extremely serious/ business.

I should say so -- an underscore requires the poor innocent (Mac)
typist to press three keys simultaneously!

Michael

>
> So how about hasElementCalled() then?
>
> Or given that these are 'names' how about
>
>   hasElementNamed()
>
> pr maybe
>
>   containsName()
>
>
> Dirk
>
> --
> R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL
> See agenda, registration details and more at http://www.RinFinance.com
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


More information about the Rcpp-devel mailing list