From luke-tierney at uiowa.edu  Thu Apr 21 22:34:18 2016
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Thu, 21 Apr 2016 15:34:18 -0500
Subject: [Rd] locked environments
In-Reply-To: <CAF8bMcbzg21p50PAHdFoicrGSWcY6P0=LXHRmLN8huNjGUmCbw@mail.gmail.com>
References: <CAF8bMcbzg21p50PAHdFoicrGSWcY6P0=LXHRmLN8huNjGUmCbw@mail.gmail.com>
Message-ID: <alpine.DEB.2.10.1604211531220.3865@luke-Latitude>

Ideally they should all work. What is happening is that the current
implementation of complex assignment wants to use a temporary variable
named *tmp*, which it can't when the evaluation environment is locked.
Assignments in compiled code use a different mechanism that I hope
will eventually be ported to the interpreter. Then these should all
work.

Best,

luke

On Wed, 20 Apr 2016, William Dunlap via R-devel wrote:

> Shouldn't the following 4 ways to alter an object in a locked environment
> either all work or all fail?  (All working would be nice, I think.)
>
>   E <- new.env()
>   assign("var", c(1,2,3,4), envir=E)
>   lockEnvironment(E, bindings=FALSE)
>   E$var[1] <- 101 ; E$var
>   #[1] 101   2   3
>   local(var[2] <- 102, envir=E)
>   #Error in eval(expr, envir, enclos) :
>   #  cannot add bindings to a locked environment
>   with(E, var[3] <- 103)
>   #Error in eval(expr, envir, enclos) :
>   #  cannot add bindings to a locked environment
>   eval(quote(var[4] <- 104), envir=E)
>   #Error in eval(expr, envir, enclos) :
>   #  cannot add bindings to a locked environment
>   get("var", envir=E)
>   #[1] 101   2   3   4
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] locked environments
luke-tierney at uiowa.edu