From r.hankin at noc.soton.ac.uk  Mon Sep  4 10:41:46 2006
From: r.hankin at noc.soton.ac.uk (Robin Hankin)
Date: Mon, 4 Sep 2006 09:41:46 +0100
Subject: [Rd] setMethod("Logic", ...)
In-Reply-To: <Pine.LNX.4.64.0609011642240.16133@gannet.stats.ox.ac.uk>
References: <91AD8AFC-E5A3-4F79-821D-CACC2705333D@soc.soton.ac.uk>
	<Pine.LNX.4.64.0609011642240.16133@gannet.stats.ox.ac.uk>
Message-ID: <7F7440CD-18B2-4AB6-B0BA-6DB0B0491727@soc.soton.ac.uk>

Professor Ripley

thank you for this (and indeed thank you for solving my earlier
problem on octonions).

I still don't know how  to force logic operations on brob objects to  
give an error.


06, at 16:45, Prof Brian Ripley wrote:

> Accordng to the S4groupGeneric page, there is no such group.
>
> My guess as to why:
>
> Those operators are not S3 generic in R, and S4 dispatch is piggy- 
> backed
> on S3 dispatch (not necessarily, but for convenience).
>
>



I have been trying to use the  example on p119 of S Programming as
a template:


setClass("brob",
          representation = representation 
(x="numeric",positive="logical"),
          prototype      = list(x=numeric(),positive=logical())
          )


.logicBrob <- function(e1,e2){
   stop("No logic currently implemented for Brobdingnagian numbers")
}


setMethod("Logic",signature(e1="brob"), .logicBrob)
setMethod("Logic",signature(e2="brob"), .logicBrob)



but this does not work as desired (setMethod() gives an error).  I want,
for example,

!new("brob", x=1:10,positive=rep(T,10))

to call .logicBrob() and report an error.





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




[Rd] setMethod("Logic", ...)
Robin Hankin