On Fri, Jul 11, 2008 at 08:00:40PM -0700, Bob Rogers via RT wrote: > Of course, if cloning works the same as newclosure than we don't > need an explicit newclosure for the examples given, because > assignment already makes a clone. > > Assignment seems to do assign_pmc, which for a closure invokes the Sub > method (there is no Closure method). Needless to say, Sub:assign_pmc > does nothing special to capture the current context; if that is NULL, > then "autoclose" takes over when the thing is called.
You're _completely_ missing my point. If we follow my proposal to modify Parrot or code generation such that a capture operation is performed for closures at the beginning of every outer sub invocation, then by the time we get to an assign operation a closure would _already_ have its current context captured, so only a simple clone is needed (which is what assign normally does -- it makes a copy of whatever is being assigned). And again, under my proposal I've been saying (apparently ineffectively) that "autoclose" would be gone entirely, and invoking a Closure that hasn't already had its context captured (i.e, outer_ctx is NULL) will throw an exception. In other words, there's no chance that "autoclose takes over when the thing is called". Pm