From Thomas.Petzoldt at TU-Dresden.de  Thu Feb 25 13:02:40 2010
From: Thomas.Petzoldt at TU-Dresden.de (Thomas Petzoldt)
Date: Thu, 25 Feb 2010 13:02:40 +0100
Subject: [Rd] proto and baseenv()
In-Reply-To: <20100224233350.4e3da5db.misc7@emerose.org>
References: <20100225043854.GA26106@klutometis.wikitex.org>
	<20100224233350.4e3da5db.misc7@emerose.org>
Message-ID: <4B8666E0.4070808@TU-Dresden.de>

Am 25.02.2010 06:33, wrote Ben:
> Wow, thanks for the heads-up.  That is horrible behavior.  But using
> baseenv() doesn't seem like the solution either.  I'm new to proto,
> but it seems like this is also a big drawback:
>
>> z<- 1
>> proto(baseenv(), expr={a=z})$a
> Error in eval(expr, envir, enclos) : object "z" not found
>
>

I would say that this behaviour is intentional and not "horrible". proto 
objects do simply the same as ordinary functions in R that have also 
full access to variables and functions at a higher level:

Try the following:

 > y <- proto(a=2)
 > y$ls()
[1] "a"


ls() is defined in package base and so would even work if you inherit 
from baseenv() so why it is surprising that proto objects (by default) 
inherit objects from other packages and from the user workspace?


Thomas P.



[Rd] proto and baseenv()
Thomas Petzoldt