Skip to content
Prev 39701 / 63421 Next

How to debug reference classes?

'mtrace' will work with reference classes, at least after an object is instantiated. I'm not familiar with the guts of reference classes, but the following quick experiment was successful.. If you run the example in '?ReferenceClasses' up to & including this line :

xx <- mEditor$new(data = xMat)

and then do this:

mtrace( edit, from=attr( xx, '.xData'))

and then run the next line of the example, which is

xx$edit(2, 2, 0)

then the debug window will come up as normal.

Now, what about if you want to mtrace 'edit' before objects are instantiated? Here the S4 structure defeated me temporarily, but I probably would have been able to beat it if I'd had more time... There are some notes on debugging S4 methods in 'package?debug' (note that '?mtrace' itself is out-of-date on S4-- I have gotten S4 debugging to work, but it's only described in 'package?debug') and that might be enough to get you going.

HTH

Mark ('debug' package author)

Mark Bravington
CSIRO CMIS
Marine Lab
Hobart
Australia