From michael.weylandt at gmail.com  Tue Aug 20 22:06:14 2013
From: michael.weylandt at gmail.com (R. Michael Weylandt <michael.weylandt@gmail.com>)
Date: Tue, 20 Aug 2013 16:06:14 -0400
Subject: [Rd] Extending suggestion for stopifnot
In-Reply-To: <CAPr7RtX3b5XBzgn1XT3nPcvX71G=W1CpK=tK1T3zz4zWW=pQNQ@mail.gmail.com>
References: <CAPr7RtX3b5XBzgn1XT3nPcvX71G=W1CpK=tK1T3zz4zWW=pQNQ@mail.gmail.com>
Message-ID: <1E984682-1DA5-4793-9301-11EF1E999B84@gmail.com>



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



[Rd] Extending suggestion for stopifnot
R. Michael Weylandt <michael.weylandt@gmail.com>