From maechler at stat.math.ethz.ch  Fri Oct 10 14:35:42 2003
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri Oct 10 14:34:52 2003
Subject: [Rd] An artifact of base being namespace
In-Reply-To: <FC2BADAC-FA6E-11D7-92F4-0003931A3C9E@stat.wisc.edu>
References: <FC2BADAC-FA6E-11D7-92F4-0003931A3C9E@stat.wisc.edu>
Message-ID: <16262.42910.138312.205452@gargle.gargle.HOWL>

>>>>> "Saikat" == Saikat DebRoy <saikat@stat.wisc.edu>
>>>>>     on Thu, 9 Oct 2003 11:41:01 -0400 writes:

    Saikat> Function in the base library of R 1.8.0 seems to use
    Saikat> a search path with base coming before the local
    Saikat> environment. I think this is intentional and is
    Saikat> related to base being a namespace.

yes (intended and because base is a namespace).

     > log <- function(x, base) 200
     > log(1)
    [1] 200
     > log10
    function (x)
    log(x, 10)
    <environment: namespace:base>
     > log10(1)
    [1] 0
     >

    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.

Martin


[Rd] An artifact of base being namespace
Martin Maechler