From ggrothendieck at gmail.com  Thu Feb 28 21:46:17 2013
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Thu, 28 Feb 2013 15:46:17 -0500
Subject: [Rd] Return value of S4 validity function
In-Reply-To: <CAP01uRkz=jagOQf_7V3zKw5cBvFKWDUgJ+jiNAsv1i9eMVgxMg@mail.gmail.com>
References: <CAP01uRkz=jagOQf_7V3zKw5cBvFKWDUgJ+jiNAsv1i9eMVgxMg@mail.gmail.com>
Message-ID: <CAP01uRmRa8tRtJCtuym8RufT16eAnXu2C6WAsOnQY2tBBD2j9A@mail.gmail.com>

On Thu, Feb 28, 2013 at 3:44 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> This issues a message about a needing to be non-negative as expected:
>
> setClass("A",
>   representation = list(a = "numeric"),
>   prototype = list(a = 0),
>   validity = function(object) {
>     out <- if (object at a < 0) "a must be non-negative"
>     if (is.null(out)) TRUE else out ##
>   })
> new("A", a = -1)
>
> but it also works if the ## line is omitted so it appears that one can
> use NULL in place of TRUE.  I wonder if the use of NULL as an
> alternative to TRUE could be officially supported as it would allow
> one to write validity methods in a more concise manner.  It appears
> that this would only require a change to the documentation.
>

Pressed return too quickly.  This should have continued on to give this example:

new("A")

with and without the ## line both of which work since it appears that
NULL can be used in place of TRUE.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[Rd] Return value of S4 validity function
Gabor Grothendieck