[Rd] optional setValidity()

Robin Hankin r.hankin at noc.soton.ac.uk
Wed May 7 16:43:46 CEST 2008


Hi


Suppose I have an S4 class "foo" and a validity checking
function  ".checkfoo()":

setClass("foo",  representation=representation("numeric"))
setValidity("foo" , .checkfoo)

is fine; in my application, .checkfoo() verifies that a bunch
of necessary conditions are met.

But .checkfoo() is very time consuming and I want
to give users the option of switching it off.

Most foo objects that one deals with fall into two or three standard  
types
and in these cases one doesn't need to execute  .checkfoo()
because one can show algebraically that the conditions are
automatically met.

But OTOH, I want the check to be performed "by default" to
stop anyone (me) from being too clever and defining
a non-standard foo object that doesn't meet .checkfoo().

What is best practice here?

Are there any examples I could copy?





--
Robin Hankin
Uncertainty Analyst and Neutral Theorist,
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



More information about the R-devel mailing list