[Rd] Something strange in "?assign"? (PR#433)

J.C.Rougier@durham.ac.uk J.C.Rougier@durham.ac.uk
Fri, 11 Feb 2000 13:22:25 +0100 (MET)


According to the assign helpfile (0.90.1) the "assign" function is

function (x, value, pos = -1, envir = sys.frame(sys.parent()),
  inherits = FALSE, immediate = TRUE)

which is not quite the implementation, which is

function (x, value, pos = -1, envir = pos.to.env(pos), inherits = FALSE, 
  immediate = TRUE)

This seems to have the following interesting effect.

"short.fun" <- function() {make(); ls()}
"make" <- function() assign("x", 3, envir = sys.frame(sys.parent()))

short.fun()	# gives an x as I would expect

"make" <- function() assign("x", 3)

short.fun()	# now there's nothing here!

But since I have simply duplicated the default value, according to the
help file, I would expect these two "make" functions to behave
identically.  Is this to be expected, and if not, is this because the
definition of "assign" is slightly different to that in the help file?

Many thanks, Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html


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