> However, I think there is a way out for a good refcounting. > > As long as same anonymous subroutine always has same "xcv_start" and > "xcv_root" (whereas it could have different "xcv_padlist" > within different > invocations) this way it could be detected when same sub is used, even > within different CV. >
IOW every CV has "pad", but the code coud be the same, so I hoped to not create Tcl command when only PAD is different. Thinking deeper, I can't restore proper PAD when Tcl command invokes, or, if I store it elsewhere, and restore later, then, after CV garbage-collected, I will lost OP* tree anyways. Or I can copy OP* also to restore it later, and no memory win. looks like indeed no way doing proper refcount without going too deep. Regardless, is it reasonable to switch to "perlsub" tcl object, so those bits of code in Tcl.xs will be in their place? (with extra refcount on, so to avoid destruction) ?? Vadim.