[Rd] S4 group generic Complex not working (PR#4483)
saikat at stat.wisc.edu
Thu Oct 9 15:17:26 MEST 2003
On Thursday, Oct 9, 2003, at 12:46 US/Eastern, Prof Brian Ripley wrote:
> On Thu, 9 Oct 2003 saikat at stat.wisc.edu wrote:
>> The Complex group generic for S4 methods is not working:
>>> setClass('foo', representation(z='complex'))
>>  "foo"
>>> setMethod('Complex', 'foo', function(z) callGeneric(z at z))
>>  "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
> 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'))
> setClass('foo', representation(x='numeric'))
> setMethod('Finite', 'foo', function(x) callGeneric(x at x))
> is.finite(new('foo', x=1))
More information about the R-devel