Skip to content
Prev 44987 / 63424 Next

Contract Syntactic Sugar

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 strict enough
  x$base %::% allpositive
  x$base ^ exponent
}

multiple creations as in your doc examples on the same function are a
recipe for errors for me.  it's also why I am not too fond of
TypeInfo.  chaining conditions in my c() is not important, as long as
I can define my own types (which can check multiple aspects at the
same time).  suggestion: in your doc example, can you define a
different type than an integer?  it's a little confusing.  how about
defining a strictly positive integer?

regards,

/iaw
----
Ivo Welch (ivo.welch at gmail.com)
http://www.ivo-welch.info/
J. Fred Weston Professor of Finance
Anderson School at UCLA, C519
Director, UCLA Anderson Fink Center for Finance and Investments
Free Finance Textbook, http://book.ivo-welch.info/
Editor, Critical Finance Review, http://www.critical-finance-review.org/
On Mon, Feb 4, 2013 at 2:10 PM, Brian Lee Yung Rowe <rowe at muxspace.com> wrote: