From saikat at stat.wisc.edu  Fri Oct 10 18:00:51 2003
From: saikat at stat.wisc.edu (Saikat DebRoy)
Date: Fri Oct 10 17:59:04 2003
Subject: [Rd] An artifact of base being namespace
In-Reply-To: <16262.42910.138312.205452@gargle.gargle.HOWL>
Message-ID: <EBCCB760-FB3A-11D7-92F4-0003931A3C9E@stat.wisc.edu>

On Friday, Oct 10, 2003, at 08:35 US/Eastern, Martin Maechler wrote:

>>>>>> "Saikat" == Saikat DebRoy <saikat@stat.wisc.edu>
>>>>>>     on Thu, 9 Oct 2003 11:41:01 -0400 writes:
>
>     Saikat> This is most problematic when you are creating a
>     Saikat> generic for an existing function in base (as you
>     Saikat> very well could for log). This often makes the
>     Saikat> ability to make new generics out of existing
>     Saikat> functions somewhat useless.
>
> Assuming you're right, I'm much less sure that this consequence
> has been intended in all situations.  But I'd need to see
> concrete examples to understand your last sentence.
>

Here is an example of what I was saying.

 > setClass('foo', representation(x='numeric'))
[1] "foo"
 > setMethod('log', signature(x='foo', base="missing"),
+  function(x, base) callGeneric(x@x))
[1] "log"
 > setMethod('log', 'foo', function(x, base)
+  callGeneric(x@x, base))
[1] "log"
 > log(new('foo', x=100))
[1] 4.60517
 > log10(new('foo', x=100))
Error in log(x, base) : Non-numeric argument to mathematical function
 >

This means that if I create a generic for 'log', I should also create a 
generic for each function in base that makes a call to 'log'. That is 
not what I expected.


[Rd] An artifact of base being namespace
Saikat DebRoy