On Thursday, Oct 9, 2003, at 12:46 US/Eastern, Prof Brian Ripley wrote:

On Thu, 9 Oct 2003 [EMAIL PROTECTED] wrote:

The Complex group generic for S4 methods is not working:

setClass('foo', representation(z='complex'))
[1] "foo"
setMethod('Complex', 'foo', function(z) callGeneric([EMAIL PROTECTED]))
[1] "Complex"
Arg(new('foo', z=1+0i))
Error in Arg(new("foo", z = 1 + (0+0i))) :
         non-numeric argument to function


The fix is to add

     if (DispatchGroup("Complex", call, op, args, env, &x))
        return x;

near the beginning of do_cmathfuns in complex.c.

I don't think that's right: that would set up an S3 group generic
Complex, and there is no such thing. That's not how S4 group generics are
implemented, according to ?Complex.



The problem may be with setGroupGeneric. Here is one example where it is not working.


> setGroupGeneric('Finite', function(x) NULL, c('is.finite', 'is.infinite', + 'is.na', 'is.nan'))
[1] "Finite"
> setClass('foo', representation(x='numeric'))
[1] "foo"
> setMethod('Finite', 'foo', function(x) callGeneric([EMAIL PROTECTED]))
[1] "Finite"
> is.finite(1)
[1] TRUE
> is.finite(new('foo', x=1))
logical(0)
>


______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

Reply via email to