Skip to content
Prev 14153 / 63458 Next

Destructive str(...)?

Luke Tierney <luke@stat.uiowa.edu> writes:
Argh. I think this means that there is a bug in the tcltk code since
tclObj class objects are exactly external references with a class
attribute. It doesn't seem to have bitten anyone yet, though. Or were
you saying that we should fix str() instead?

Anyways, Tcl objects do provide a rather nice illustration of why
reference objects are non-duplicatable (which is the reason behind
unclass being destructive). They have a finalizer that decrements the
Tcl reference count when the R object is destroyed. To avoid bad
things resulting from decreasing the refcount multiple times,
duplication would require an increment of the reference count, and R
just isn't geared to do that: we'd need to introduce something like an
R_RegisterCDuplicator function.