RE: [Rd] str() resets class for environments

From: <Mark.Bravington_at_csiro.au>
Date: Wed 24 Nov 2004 - 11:42:36 EST


Henrik Bengtsson wrote:

> Should attr()<-, attributes()<-,
> class()<- give an error when applied to an environment? I see
> no reason why
> not.

It would break the workspace-organization code in the 'mvbutils' package, which relies on being able to set and unset attributes of environments on the search path (specifically, the 'name' and 'path' attributes).

So personally I'd much prefer not to have this happen! For the wider R community, I'm not sure how many users the 'mvbutils' package has, but I think it's a fair number judging from emails I get.

If you do feel the extra security is vitally important, perhaps there could be 'lock.attributes' and 'unlock.attributes' functions for environments. The idea would be that each environment has an invisible (i.e. internal) mock-attribute "locked", which would be TRUE by default (on creation of the environment). While "locked" is TRUE, any attempt to muck about with the environment's attributes would cause an error. But if you really did need to change attributes of that , it would still be possible by calling 'unlock.attributes' first.

Mark


Mark Bravington
CSIRO (CMIS)
PO Box 1538
Castray Esplanade
Hobart
TAS 7001 phone (61) 3 6232 5118
fax (61) 3 6232 5012

Mark.Bravington@csiro.au



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 24 11:51:16 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:01:43 EST