From ripley@stats.ox.ac.uk  Wed Jul 12 09:05:09 2000
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Wed, 12 Jul 2000 09:05:09 +0100 (BST)
Subject: [Rd] buglet in fix() [was "function via source or fix"] (PR#602)
In-Reply-To: <200007120635.IAA00523@pubhealth.ku.dk>
Message-ID: <Pine.GSO.4.05.10007120858480.18731-100000@auk.stats>

On Wed, 12 Jul 2000 maechler@stat.math.ethz.ch wrote:

> >>>>> "Erin" == Erin Hodgess <hodgess@uhddx01.dt.uh.edu> writes:
> 
>     Erin> Suppose I create a function, x.e, via the fix command:
> 
> (ESS users ESS don't ever do this, but still ...)
> 
>     >> x.e <- fix(x.e)
> 
>     Erin> When I type in x.e, the function code appears, along
>     Erin> with the name/number of the environment.
> 
> Ok, in the above it was important that there's no *existing* object x.e 
> beforehand.
> 
> Note that the idea about  fix() is that you only have to write
> 
>      fix(x.e)
> 
> But your problem remains :
> 
>     > fix(newerf)
>     Waiting for Emacs...Done	--- I have  options(editor = "emacsclient")
>     > newerf
>     function ()
>     {
>     ## newer
>     }
>     <environment: 0x40862004>
>     > environment(newerf)
>     <environment: 0x40862004>
>     > ls(env=environment(newerf))
>     [1] "subx" "x"   
>     >
> 
> I.e. it got the environment of the function fix -- I think this is clearly
> a bug  CC'ed to  R-bugs

And the fix is easy: just add

environment(x) <- .GlobalEnv

in that branch of the if.  Now committed to the R-patched branch.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] buglet in fix() [was "function via source or fix"] (PR#602)
Prof Brian D Ripley