Re: [Rd] Contract Syntactic Sugar

2013-02-04 Thread Brian Lee Yung Rowe
Ivo, If you don't like the multipart function syntax you can write a single definition. Personally I prefer this as it isolates data management logic and control flow from model/application logic. There are duck typing operators that you can use in the guard similar to the syntax you wrote. You

Re: [Rd] Contract Syntactic Sugar

2013-02-04 Thread ivo welch
hi brian---interesting and very impressive. is it possible to move everything into one definition and/or to chain multiple conditions? exponentiate(x, exponent) %::% data.frame : c(numeric,allpositive) : integer %as% { x %has% base ## my invention, since this is not checked, and R is not stri

Re: [Rd] Contract Syntactic Sugar

2013-02-04 Thread Brian Lee Yung Rowe
Ivo, You might be interested in my lambda.r package which provides syntax (using the %::% operator) for type constraints. Given a function with n arguments, the type constraint requires n + 1 types, as the last type listed is the return type. Lambda.r also provides syntax for specifying any ar

Re: [Rd] Contract Syntactic Sugar

2013-02-04 Thread Gabriel Becker
Ivo, Have you looked at the TypeInfoBioConductor 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 di

[Rd] Contract Syntactic Sugar

2013-02-04 Thread ivo welch
## 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##