Hi Martin, Thanks. Your remark about setValidity makes sense. One question about try() though. Isn't that a (crude) implementation of duck typing? Give a method some type of data, 'try' if it works with that type of data, and if not, do something else? I think I agree with you that if-then is less of a "let's see what happens" kind of statement.
Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the face of ambiguity, refuse the temptation to guess. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- On Mon, 3/8/10, Martin Morgan <mtmor...@fhcrc.org> wrote: From: Martin Morgan <mtmor...@fhcrc.org> Subject: Re: [R] setClass or setValidity? To: "Albert-Jan Roskam" <fo...@yahoo.com> Cc: r-help@r-project.org Date: Monday, March 8, 2010, 10:56 PM On 03/08/2010 07:18 AM, Albert-Jan Roskam wrote: > Sorry: there was an error in the last sentence: > And, inside those validity checks, is most of the checking done with 'if' > 'else' computations, or is it also common to use try()? For me it's a matter of taste, and usual to use if... (because you know explicitly what you're trying to validate, whereas try() implies a kind of 'something might go wrong...'). I find myself using setValidity() to separate out class definition from implementation. Best, Martin > > Cheers!! > Albert-Jan > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In the face of ambiguity, refuse the temptation to guess. > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > --- On Mon, 3/8/10, Albert-Jan Roskam <fo...@yahoo.com> wrote: > > > From: Albert-Jan Roskam <fo...@yahoo.com> > Subject: [R] setClass or setValidity? > To: r-help@r-project.org > Date: Monday, March 8, 2010, 4:14 PM > > > Hi, > > I'm reading up on S4 classes *). There seem to be at least two ways of input > validation: > setClass() (using the 'validity' argument) and setValidity(). Is it a matter > of taste which function is used? Or should more complex validation code > better be put in a setValiditity call? > > *) A (Not So) Short Introduction to S4 Object Oriented Programming in R > V0.5.1 Christophe Genolini August 20, 2008 > > And, inside those validity checks, is most of the checking done with 'if' > 'else' computations, or is it also common to use except()? > > Cheers!! > Albert-Jan > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In the face of ambiguity, refuse the temptation to guess. > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > [[alternative HTML version deleted]] > > > -----Inline Attachment Follows----- > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > > > [[alternative HTML version deleted]] > > > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.