Skip to content
Prev 53472 / 63424 Next

stopifnot() does not stop at first non-TRUE argument

Hello,

I am a new on this list, so I introduce myself very briefly:
my background is applied mathematics, more precisely scientific calculus
applied for modeling metabolic systems, I am author/maintainer of
few packages (Deriv, rmumps, arrApply).

Now, on the subject of this discussion, I must say that I don't really understand
Peter's argument:

     >>> To do it differently, you would have to do something like
     >>>
     >>> dots <- match.call(expand.dots=FALSE)$...
     >>>
     >>> and then explicitly evaluate each argument in turn in the caller
     >>> frame. This amount of nonstandard evaluation sounds like it would
     >>> incur a performance penalty, which could be undesirable.
The first line of the current stopifnot()
n <- length(ll <- list(...))
already evaluates _all_ of the arguments
in the caller frame. So to do the same only
on a part of them (till the first FALSE or NA occurs)
cannot be more penalizing than the current version, right?

I attach here a slightly modified version called stopifnot_new()
which works in accordance with the man page and
where there are only two additional calls: parent.frame() and eval().
I don't think it can be considered as real performance penalty
as the same or bigger amount of (implicit) evaluations was
already done in the current version:
Error: 3 == 5 is not TRUE
Error: object 'a' not found

Best,
Serguei.


Le 15/05/2017 ? 10:39, Martin Maechler a ?crit :

Thread (22 messages)

Hervé Pagès stopifnot() does not stop at first non-TRUE argument May 2 Peter Dalgaard stopifnot() does not stop at first non-TRUE argument May 3 Hervé Pagès stopifnot() does not stop at first non-TRUE argument May 3 Hervé Pagès stopifnot() does not stop at first non-TRUE argument May 3 Martin Maechler stopifnot() does not stop at first non-TRUE argument May 15 Serguei Sokol stopifnot() does not stop at first non-TRUE argument May 15 Serguei Sokol stopifnot() does not stop at first non-TRUE argument May 15 Martin Maechler stopifnot() does not stop at first non-TRUE argument May 15 Peter Dalgaard stopifnot() does not stop at first non-TRUE argument May 15 Serguei Sokol stopifnot() does not stop at first non-TRUE argument May 15 Martin Maechler stopifnot() does not stop at first non-TRUE argument May 15 Peter Dalgaard stopifnot() does not stop at first non-TRUE argument May 15 Martin Maechler stopifnot() does not stop at first non-TRUE argument May 15 Serguei Sokol stopifnot() does not stop at first non-TRUE argument May 15 Luke Tierney stopifnot() does not stop at first non-TRUE argument May 15 Hervé Pagès stopifnot() does not stop at first non-TRUE argument May 15 Hervé Pagès stopifnot() does not stop at first non-TRUE argument May 15 Martin Maechler stopifnot() does not stop at first non-TRUE argument May 16 Serguei Sokol stopifnot() does not stop at first non-TRUE argument May 16 Luke Tierney stopifnot() does not stop at first non-TRUE argument May 16 Luke Tierney stopifnot() does not stop at first non-TRUE argument May 16 Martin Maechler stopifnot() does not stop at first non-TRUE argument May 16