From saikat@stat.wisc.edu  Fri Sep 15 20:09:46 2000
From: saikat@stat.wisc.edu (Saikat DebRoy)
Date: 15 Sep 2000 14:09:46 -0500
Subject: [Rd] classed
In-Reply-To: Douglas Bates's message of "15 Sep 2000 12:47:28 -0500"
References: <3.0.32.20000915142129.0129d2d0@pophost.nsw.cmis.csiro.au> <20000915165809.I24267@ftoomsh.progsoc.uts.edu.au> <39C245E0.A2B36FA6@bank-banque-canada.ca> <6rn1h9mtsf.fsf@franz.stat.wisc.edu>
Message-ID: <qxp1yylii9x.fsf@verdi.stat.wisc.edu>

I decided to experiment with this a little. I use a little C function
called printAddress that prints the address of an R object to standard
error.

> x <- 1
> .Call("printAddress", x)
0x891fedc
NULL
> x <- classd(x, "a")
> .Call("printAddress", x)
0x891fd2c
NULL

So the address has changed. Now we can go inside a debugger and see if
do_classgets has anything to do with it.

...

> x <- 1
> .Call("printAddress", x)
0x891fc78
NULL
> x <- classd(x, "a")
# now go to debugger
Breakpoint 1, do_classgets (call=0x89221f0, op=0x81d6720, args=0x8922164, 
    env=0x8922298) at ../../../r-devel/src/main/attrib.c:315
(gdb) p args->u.listsxp.carval
$7 = (struct SEXPREC *) 0x8921aa8
(gdb) n
(gdb) n
(gdb) n
(gdb) p args->u.listsxp.carval
$9 = (struct SEXPREC *) 0x8921aa8
(gdb) n
Rf_eval (e=0x89221f0, rho=0x8922298) at ../../../r-devel/src/main/eval.c:335

So do_classgets does not change the 
(gdb) c
Continuing.
# now we are back to R
> .Call("printAddress", x)
0x89219f4
NULL

The interesting thing is that the object address changed twice. That
is, x is getting copied twice - once after classd is called but before
setting the class and another time when it returns from classd. I was
expecting the second change but not the first.

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


[Rd] classed
Saikat DebRoy