Re: [Rcpp-devel] Avoiding memory allocations when using Armadillo, BLAS, and LAPACK

2015-02-18 Thread Nathan Kurz
On Wed, Feb 18, 2015 at 8:00 AM, Dirk Eddelbuettel wrote: > It is a little challenging to keep up with your ability to ask this question > here, on StackOverflow and again on r-devel. As I first saw it here, I'll > answer here. Sorry about that. I was planning to do it first only on StackOverflo

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Dale Smith
I haven't been very active lately with Rcpp, but I like Nathan's advice below. Don't redefine assert(), I think that's not friendly to inexperienced people and will just generate more questions. Dale Smith, Ph.D. | Data Scientist | nexidia | office: +1 404 495 7220 ext 4008 | fax: +1 404 495 72

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Nathan Kurz
On Tue, Feb 17, 2015 at 4:41 PM, Miratrix, Luke wrote: > The proposed code: > > #include > > #ifdef NDEBUG > # define assert(EX) > #else > # define assert(EX) (void)((EX) || (__assert (#EX, __FILE__, __LINE__),0)) > #endif > > void __assert (const char *msg, const char *file, int line) { > ch

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Kevin Thornton
Thanks--this helps. I have a project based on Rcpp and another header-only library where this could have been an issue. > On Feb 18, 2015, at 10:53 AM, Dirk Eddelbuettel wrote: > > > On 18 February 2015 at 09:31, Kevin Thornton wrote: > | Hi Dirk, > | > | Thanks. I did check the recent Rcpp

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Dirk Eddelbuettel
On 18 February 2015 at 09:31, Kevin Thornton wrote: | Hi Dirk, | | Thanks. I did check the recent Rcpp announcement, which corresponds to my installed version, and mentions nothing re: assert (https://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg07977.html). See eg htt

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Tim Keitt
On Wed, Feb 18, 2015 at 10:53 AM, Dirk Eddelbuettel wrote: > > So now that this has been taken care of, we are discussing how to provide a > more useful feature "not unlike assert" with proper Rcpp semantics. > > Something like: #define stopifnot(a) if (!(a)) stop(#a) ? THK -- http://www.kei

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Dirk Eddelbuettel
On 18 February 2015 at 11:22, Dirk Eddelbuettel wrote: | | Hi Kevin, | | On 18 February 2015 at 09:02, Kevin Thornton wrote: | | Hi Dirk, | | | | Sorry, but your response is unclear to me. What was "taken care of"? What is 'tinyformat'? Are you trying to say that this method of defining ass

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Kevin Thornton
Hi Dirk, Thanks. I did check the recent Rcpp announcement, which corresponds to my installed version, and mentions nothing re: assert (https://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg07977.html). --Kevin > On Feb 18, 2015, at 9:22 AM, Dirk Eddelbuettel wrote: > > > H

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Dirk Eddelbuettel
Hi Kevin, On 18 February 2015 at 09:02, Kevin Thornton wrote: | Hi Dirk, | | Sorry, but your response is unclear to me. What was "taken care of"? What is 'tinyformat'? Are you trying to say that this method of defining assert will work with any other C++ library that includes ? May I sugge

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Kevin Thornton
Hi Dirk, Sorry, but your response is unclear to me. What was "taken care of"? What is 'tinyformat'? Are you trying to say that this method of defining assert will work with any other C++ library that includes ? --Kevin > On Feb 18, 2015, at 8:53 AM, Dirk Eddelbuettel wrote: > > > On 18 F

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Dirk Eddelbuettel
On 18 February 2015 at 08:34, Kevin Thornton wrote: | Isn't there a potential issue if a package depends on multiple header-only C++ libraries, each of which may include ? You'd have multiple definitions of the macro floating around, and the compiler will barf. Been there, done that -- this wh

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Kevin Thornton
Isn't there a potential issue if a package depends on multiple header-only C++ libraries, each of which may include ? You'd have multiple definitions of the macro floating around, and the compiler will barf. --Kevi > On Feb 17, 2015, at 4:41 PM, Miratrix, Luke wrote: > > > Dirk Eddelbuettel

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread JJ Allaire
We *can* call Rf_error from C++ code, but when we do it bypasses all C++ destructors on the stack, so we don't do it so as not leak memory and otherwise have deterministic behavior around construction/destruction. You'll notice in Dirk's example that there are no C++ objects on the stack when he c

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-18 Thread Sparapani, Rodney
On Tue, 2015-02-17 at 17:53 -0700, JJ Allaire wrote: > One piece of immediate feedback on your initial implementation: you > can't call Rf_error from C++ code (as it will bypass C++ destructors > on the stack). Rather, you should throw Rcpp::exception. Hi JJ: Ok, this puzzles me. We can't call R

Re: [Rcpp-devel] Avoiding memory allocations when using Armadillo, BLAS, and LAPACK

2015-02-18 Thread Dirk Eddelbuettel
Nathan, It is a little challenging to keep up with your ability to ask this question here, on StackOverflow and again on r-devel. As I first saw it here, I'll answer here. R is a dynamically-typed interpreted language with many bells and whistles, but also opaque memory management. My recommend