[R] type checking --- just a thought

ivo welch ivo.welch at yale.edu
Fri May 14 16:22:31 CEST 2004


hi:  would it be useful to build into R an optional mechanism that 
typechecks arguments?  for example,

    sum.across <- function (  inpmatrix : matrixtype( dim[1]>1, dim[2]>3 
) ) : vector { }
       # this would define a sum.across function that can take matrices 
or data sets, but not vectors,
       # and which indicates that it will return a vector.

    xsum <- sum.across( 1:10 );  # error

    repeat <- function( series : vector( dim>0 ),  times : scalar( 
value>0 ) ) : vector;

similarly, a common input error condition may be calling a function with 
a NULL vector, or with a vector with fewer than N observations.  many 
statistical functions have such hard-wired limits.  I know that "if" 
statements can do this, but this might make for a nice standardized 
language feature.  on the other hand, the effort and complexity may not 
be worth the extra functionality.

and one beg to the language maintainers for something that I hope is simple:

    in R 1.8.2, please add to the "source" function information where 
(file:linenumber) dies or ends.

regards,

/ivo




More information about the R-help mailing list