Re: [Rd] Extending suggestion for stopifnot

2013-08-21 Thread ivo welch
thx to everyone for having listened to my suggestion and reasoning through it, even though it won't fly. maybe, as a last word, let me add a short appeal that is more generic: R is a tough programming language for beginners. anything that allows a user to request additional error-checking, and/o

Re: [Rd] Extending suggestion for stopifnot

2013-08-21 Thread Geoff Jentry
first, I think it would be more useful if it had an optional character string, so users could write stopifnot( is.matrix(m), "m is not a matrix" ) stop() allows for arbitrary strings __ R-devel@r-project.org mailing list https://stat.ethz.ch/mai

Re: [Rd] Extending suggestion for stopifnot

2013-08-21 Thread Deepayan Sarkar
On Wed, Aug 21, 2013 at 3:30 AM, ivo welch wrote: > thx, deepayan: how is stopifnot better than > if (!all(...)) stop() But I am not claiming that it is! If you think it is not useful, then don't use stopifnot(), use stop() instead, and tell your students to do so as well. > given that we

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread Martin Morgan
On 08/20/2013 11:41 AM, ivo welch wrote: A second enhancement would be a "smart string", which knows that everything inside {{...}} should be evaluated. stopifnot( is.matrix(m), "m is not a matrix, but a {{class(m)}}" ) a variant with more traditional syntax might be if (!is.matrix(m))

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread Hadley Wickham
> first, I think it would be more useful if it had an optional character > string, so users could write > > stopifnot( is.matrix(m), "m is not a matrix" ) > Another option is to just generate better error messages automatically, e.g.: > library(assertthat) > x <- 1:10 > assert_that(is.matrix(x)

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread ivo welch
functionality is nice. syntax is weird. I think I would have preferred an "interpolate" function call. stop( i("class is `class(pi)` and $pi") ) three typing letters, too, and more logical. most importantly, I wish we had some form of this in base R from the outset--whatever it is--so that m

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread Gabor Grothendieck
On Tue, Aug 20, 2013 at 6:00 PM, ivo welch wrote: > character string at the end of an existing function, stopifnot(). (2) > I think "estrings" (that behave like characters but are interpolated > before printout) are useful in the same way perl interpolated strings > are useful. The gsubfn packag

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread ivo welch
thx, deepayan: how is stopifnot better than if (!all(...)) stop() given that we have stopifnot() and I have seen it used often, I think my two suggestions would make it better. thx, michael: the %and% and %or% constructs are indeed relics of my perl background. my own definition is `%and%`

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread Brian Rowe
If all you care about is emulating static type checking, then you can also accomplish the same thing with lambda.r using type constraints on function definitions. e.g. > f(m) %::% matrix : matrix > f(m) %as% { m } > f(as.data.frame(matrix(rnorm(12),nrow=3))) Error in UseFunction("f", ...) : No

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread William Dunlap
boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On > Behalf > Of ivo welch > Sent: Tuesday, August 20, 2013 11:42 AM > To: r-devel@r-project.org List > Subject: [Rd] Extending suggestion for stopifnot > > I am using a variant of stopifnot a lot. can I suggest that b

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread Peter Langfelder
On Tue, Aug 20, 2013 at 11:41 AM, ivo welch wrote: > I am using a variant of stopifnot a lot. can I suggest that base R > extends its functionality? I know how to do this for myself. this is > a suggestion for beginners and students. I don't think it would break > anything. > > first, I think

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread R. Michael Weylandt
On Aug 20, 2013, at 14:41, ivo welch 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

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread Deepayan Sarkar
On Wed, Aug 21, 2013 at 12:11 AM, ivo welch wrote: > I am using a variant of stopifnot a lot. can I suggest that base R > extends its functionality? I know how to do this for myself. this is > a suggestion for beginners and students. I don't think it would break > anything. > > first, I think

[Rd] Extending suggestion for stopifnot

2013-08-20 Thread ivo welch
I am using a variant of stopifnot a lot. can I suggest that base R extends its functionality? I know how to do this for myself. this is a suggestion for beginners and students. I don't think it would break anything. first, I think it would be more useful if it had an optional character string,