From p.dalgaard@biostat.ku.dk  Mon Oct 14 14:54:36 2002
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 14 Oct 2002 15:54:36 +0200
Subject: The class attribute on an environment seems buggy (PR#2159)
In-Reply-To: <3DAABFBF.F7AEC086@research.bell-labs.com>
References: <200210132334.BAA05124@pubhealth.ku.dk>
 <3DAABFBF.F7AEC086@research.bell-labs.com>
Message-ID: <x23cr93z37.fsf@biostat.ku.dk>

John Chambers <jmc@research.bell-labs.com> writes:

> Would there be a problem with a "fix" in which the environment was left
> unduplicated, but environments with attributes are "duplicated" by
> creating a copy of the attribute list, but with the copy still pointing
> to the same environment?
> 
> If that is not possible, it would be good to have another datatype that
> had roughly those properties.  Otherwise, it's difficult to build on
> this datatype in designing new classes.
> 
> (The same issue applies to other types, such as external pointers.)

I've been wrapping such environments in lists, as in

> tclVar
function (init = "") 
{
    n <- evalq(TclVarCount <- TclVarCount + 1, .TkRoot$env)
    name <- paste("RTcl", n, sep = "")
    l <- list(env = new.env())
    assign(name, NULL, envir = l$env)
    reg.finalizer(l$env, function(env) tkcmd("unset", ls(env)))
    class(l) <- "tclVar"
    tclvalue(l) <- init
    l
}

where the list(env = new.env()) construct is to avoid sticking a class
directly on "env". 

What you're suggesting would seem to have the same effect, i.e. the
environment gets effectively embedded in a structure on which you can
set attributes. It does sound like it could work.

I'm just a little worried whether it would be clear enough to the end
user what is going on, or whether we'd just be compounding problems of
duplications that don't duplicate...

BTW, this was never a bug...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


The class attribute on an environment seems buggy (PR#2159)
Peter Dalgaard BSA