From pinard at iro.umontreal.ca  Tue May  9 03:03:55 2006
From: pinard at iro.umontreal.ca (=?iso-8859-1?Q?Fran=E7ois?= Pinard)
Date: Mon, 8 May 2006 21:03:55 -0400
Subject: [Rd] "Unfelicity" :-) with edit()
Message-ID: <20060509010355.GA25342@alcyon.progiciels-bpi.ca>

Hi, people.  This is about R 2.3.0 under Linux.

It seems that edit() may change a function environment.  Here is 
a transcript, more comments follow:

======================================================================>
> fix(f)

> f
function ()
{
}

> fix(f)
Erreur dans edit(name, file, title, editor) :
        une erreur s'est produite ? la ligne 3
 utilisez une commande du genre
 x <- edit()
 pour corriger

> f <- edit()

> f
function ()
{
}
<environment: base>
======================================================================<

The initial ``fix(f)`` called an editor, which I exited right away.  For 
the second ``fix(f)``, I used the editor for adding a slash between 
braces, and exited.  The French comment produced by R speaks about an 
error at line 3 and suggests using something like ``x <- edit()`` to 
make a correction.  On the third call to the editor, I remove the slash 
and exit.  Now, the environment of the function became "base".

This has unfortunate effects when editing a more substantial function, 
because for example, "stats" or "utils" is not readily available anymore 
after the editing.  Is it reasonable to suggest an improvement in the 
mechanics of edit(), for alleviating this drawback ?

-- 
Fran?ois Pinard   http://pinard.progiciels-bpi.ca



[Rd] "Unfelicity" :-) with edit()
=?iso-8859-1?Q?Fran=E7ois?= Pinard