> > You can't predict when the last time a module is going to get used... > > I'm not suggesting you need to. I'm saying that, just as all > UNITCHECKs are > guaranteed to run before any main CHECK, we might want a UNITEND that's > guaranteed to execute before any main END.
Perhaps this is one of those places where properties can help. Instead of having BEFORE, REALLY_BEFORE, NO_I_MEAN_REALLY_BEFORE, DONE, MOSTLY_DONE, PARTIALLY_DONE, WELL_DONE, DONE_AND_PROCESS_SPACE_ALMOST_RECLAIMED, etc., we could simply use some ordering properties: # Each "broad class" of upcased block is an execution group. The entries # in each execution group are not guaranteed to run in any particular order, # and in fact may run in parallel on a multithreaded perl. # # However, blocks in the same source file are guaranteed to run in order of # occurrence. (Since they're catenated, basically.) # # Thus, all "BEGIN" blocks in a file are effectively catenated and added to # an overall "BEGIN" execution group. All the separate BEGIN entries have # the same initial priority(10), so they will run in whatever order suits # the P6 runtime. # # The C<go> property introduces changes to the execution group and/or # priority of the block in question. (Note that different priorities may # be attached to different blocks within the same file. Doing so creates # separate execution bundles, and breaks any guarantees about order of # execution.) # package OtherPackage; BEGIN will go <first> { print "first!"; } package SomePackage; BEGIN will go <after OtherPackage::BEGIN> { print "Second!"; } END will go <priority 5> { print "End block with early priority"; } package ThirdPackage; END will go <group BEGIN before SomePackage::BEGIN> { print "I feel really out of place!"; } Comment? =Austin