Re: [R] Referring to objects themselves

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun, 20 Mar 2011 00:18:17 -0400

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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 20 Mar 2011 - 04:21:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Mar 2011 - 04:40:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive