From r.hankin at noc.soton.ac.uk  Wed May  7 16:43:46 2008
From: r.hankin at noc.soton.ac.uk (Robin Hankin)
Date: Wed, 7 May 2008 15:43:46 +0100
Subject: [Rd] optional setValidity()
Message-ID: <36166986-202B-4CD6-8AE9-DE17296742DB@noc.soton.ac.uk>

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



[Rd] optional setValidity()
Robin Hankin