[R] Referring to objects themselves

Gabor Grothendieck ggrothendieck at gmail.com
Sun Mar 20 05:18:17 CET 2011


On Sun, Mar 20, 2011 at 12:10 AM, Russ Abbott <russ.abbott at gmail.com> wrote:
> Actually I'm a big Haskell fan. So I think of functional programming very
> positively.  However, the environment() function doesn't seem to be treated
> functionally.  If I write
>    this <- environment()
> at the top of the previous example, the other functions and the variables
> they are bound to are inserted into the environment which had already been
> bound to 'this' afterwards.
>
> In fact, even when it is left at the end that line inserts 'this' into the
> environment, which strictly speaking it shouldn't do. So there seem to be
> some not-quite-functional processes going on.
>

this <- environment() does not create an environment.  It merely
allows this to refer to the environment that was already there and is
what holds the variables created during the execution of the function.


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list