On Aug 18, Dave Mitchell wrote: > On Mon, Aug 18, 2003 at 05:45:29PM +0100, Simon Cozens wrote: > > My initial reaction is that calling a destructor on a sub that happens > > to be a closure and not on one that doesn't is not just an unexpected > > special case, but it's surely a bug. Why (and I ask this honestly, not > > rhetorically) is it supposed to be so hard to fix? > > Assuming that we wish to keep the optimisation of sharing non-closure anon > CVs, then the problem is that by the time you try to bless the coderef, > its already pointing to the shared CV, and you're buggered. By then, you > don't really have the option of unsharing it. At least I can't think of > a clean way. It seems very strange to me to say that an anonymous sub with no private variables is "not a closure." Is not the (shorthand) definition of a closure "a subroutine, associated with all its bindings," even when "all" == 0? It's great that we have the optimization of not cloning CV's unnecessarily. It's unfortunate that we have the misfeature of Simon's no-DESTRUCT behavior. It's needlessly confusing to say that anonymous subs that have no private bindings aren't closures. Remember the etymology of "closure." It's from set theory. The empty set is a subset of *all* sets. - KurtThread Previous | Thread Next