Re: [R] an assert() function

2013-02-12 Thread Greg Minshall
Duncan, thanks for the response. stopifnot() looks almost right. it's very useful if assertion failures issue an error message pointing at the source file/line (such as error produces); it might also be nice (but not necessary) to allow the caller to pass in a "higher level" message to be append

Re: [R] an assert() function

2013-02-12 Thread Duncan Murdoch
On 12/02/2013 9:11 AM, Greg Minshall wrote: hi. i've looked for (and not found) an assert() function. needing one, i created the following (from stop()). i'm posting it in case 1) someone sees a problem with this; and 2) someone else has a need. stopifnot() might do what you want. The trick

[R] an assert() function

2013-02-12 Thread Greg Minshall
hi. i've looked for (and not found) an assert() function. needing one, i created the following (from stop()). i'm posting it in case 1) someone sees a problem with this; and 2) someone else has a need. cheers, Greg ## an assert mechanism... assert <- function (shouldbe, ...) { if (!shoul