Skip to content
Prev 22354 / 398502 Next

variable scope

Passing variables to functions "by reference" is possible, if you must, but
not recommended.  Some functions already do this, for example

	fix(myfunc)

will alter the value of `myfunc' in the present environment.  

If you can stand a piece of admittedly avuncular advice, I'd say look again
at your problem and see if you really do want to do this.  With a
programming language it is usually the case that you are better off
understanding and working within its logic and philosophy rather than trying
to make it behave in a way that you think it should.

If you still want to go through with this, you might want to look at Thomas
Lumley's article on Macros in the Programmer's Niche section of R-news a
couple of issues ago.  Using call by reference is very similar to using
macros instead of true functions.  I personally think it is both dangerous
and unnecessary, but Thomas points out that if you must it can be done
reasonably elegantly.

Sigh.

Bill Venables.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._