Ivo, Have you looked at the TypeInfo<http://www.bioconductor.org/packages/2.12/bioc/html/TypeInfo.html>BioConductor package by Gentleman and Temple Lang?
I don't use it myself and can't speak to its current state, but from its description, and having talked to one of its authors (who, for full disclosure, is my advisor), it attempts to do what you want. Also, as an aside, "::" already means something else in R so I'm not sure that particular sugar would work well. ~G On Mon, Feb 4, 2013 at 1:53 PM, ivo welch <ivo.we...@anderson.ucla.edu>wrote: > ## the following is a dream: add some sugar syntax to allow for > contracts with teeth (in and out checking) > > > is.positive <- function(x) (all(x>0)) > > > exponentiate <- function( x ::is.data.frame , exponent ::is.numeric > is.positive) :: is.vector is.numeric { > x$base :: is.positive ## error also if base does not exist > in x; may need some special IQ > x$base^exponent > } > > should be self-explanatory. anything that has '::' means "run what is > before through all the functions after and barf if it is not true". > any other operator rather than :: or other syntax would be as > good---this is just illustratory. in the end, this code should be > viewed by R as the same as > > > exponentiate <- function( x, exponent ) { > stopifnot( is.data.frame(x) ) > stopifnot( is.numeric(exponent) ) > stopifnot( is.positive(exponent) ) > stopifnot( exists("base", "x") ) > stopifnot( is.positive( x$base ) ) > return.value <- x$base^exponent > stopifnot( is.vector(return.value) ) > stopifnot( is.numeric(return.value) ) > return.value > } > > is this a feasible summer project for a student with a prospect of > inclusion of the completed code in the R core language itself if I pay > for the development time? {or does better syntax already exist and I > am just ignorant (which I often am)?} > > regards, > > /iaw > ---- > Ivo Welch (ivo.we...@gmail.com) > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Gabriel Becker Graduate Student Statistics Department University of California, Davis [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel