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

hb@maths.lth.se hb@maths.lth.se
Mon, 14 Oct 2002 01:34:46 +0200 (MET DST)


Full_Name: Henrik Bengtsson
Version: 1.6.0, 1.5.1
OS: WinXP Pro
Submission from: (NULL) (128.250.252.82)


The following example, which I tested on both R v1.5.1 and R v1.6.0 on WinXP
Pro, shows the problem I encountered when trying to use the class attribute of
an environment:

# Define method print() for class Environment
C

print(e)
# gives:
# [1] "An Environment!"

# Exit [R]
q(save="yes")

When restarting [R] and loading the previous workspace something goes wrong(?):
% R

print(e)
# gives:
# <environment: 01BE52F4>
# attr(,"class")
# [1] "Environment"

print(class(e))
# gives: 
# [1] "Environment"

print(unclass(e))
# gives:
# <environment: 01BE52F4>
# attr(,"class")
# [1] "Environment"

str(e)
# gives because of the malfunctioning unclass():
# Class 'Environment' Class 'Environment' Class 'Environment' Class
'Environment' 
# Class 'Environment' Class 'Environment' Class 'Environment' Class
'Environment' 
# Class 'Environment' Class 'Environment' Class 'Environment' ...

Note how unclass(e) does not work properly. More importantly, it the
S3/UseMethod() method dispatching get confused and won't recognize the class
attribute. 

Cheers

Henrik Bengtsson

Home: 201/445 Royale Parade, Parkville
Office: Bioinformatics, WEHI, Parkville
+61 (0)412 269 734 (cell), +61 (0)3 9387 791 (home), +61 (0)3 9345 2324 +(lab)
hb@maths.lth.se, http://www.maths.lth.se/~hb/
Time zone: +10h UTC (Sweden +2h UTC, Calif. -7h UTC)


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._