[Rd] Extending suggestion for stopifnot

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Tue Aug 20 22:06:14 CEST 2013



On Aug 20, 2013, at 14:41, ivo welch <ivo.welch at anderson.ucla.edu> wrote:

> A second enhancement would be a "smart string", which knows that
> everything inside {{...}} should be evaluated. 

I think one the HTML templating libraries (whisker or mustache or some such) provides something not unlike this. Perhaps take a look. 

> 
>  stopifnot( is.matrix(m), "m is not a matrix, but a {{class(m)}}" )
> 
> 
> my own programming variant looks even nicer,
> 
>   is.matrix(m) %or% "m is not a matrix but a {{class(m)}}"
> 
> but requesting base R to add the %and% and %or% (or, better yet, 'and'
> and 'or') operators by default would be pushing my luck.

Does %or% throw an error or is this wrapped in something else?

The former seems rather perl-ish, but the latter might suggest you look into the || and && operators if you only know their single counterparts. 

Michael

> 
> /iaw
> 
> 
> ----
> Ivo Welch (ivo.welch at gmail.com)
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list