[Rd] An artifact of base being namespace

Duncan Murdoch dmurdoch at pair.com
Sat Oct 11 01:12:50 MEST 2003

On Fri, 10 Oct 2003 14:35:42 +0200, you wrote:

>    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.

I think this depends on whether we want all simple functions to act
like generics, or whether we want a distinction.  Does it ever matter
to a function in base like log10 whether log is a simple function or a

If so, then the current behaviour is right.  Whoever wrote those
functions back in the mists of time expected log to be a simple
function, so the namespace should guarantee that it stays as one until
explicitly changed within the namespace.

But if the distinction between generics and simple functions is only
for efficiency (dispatching a generic is slower), then I think the
generic should be created in the namespace where the simple function
was originally declared.  Then log10 would call the generic which
would dispatch to the newly created method for Saikat's data.

My feeling is that the latter is what we really want.

Duncan Murdoch

More information about the R-devel mailing list