Larry Wall wrote:

On Fri, Mar 05, 2004 at 06:45:58PM -0000, Rafael Garcia-Suarez wrote:
: Of course :) the main problem is not that CHECK blocks are executed
: late (just at the end of the compilation phase); it's that they're
: executed too early, notably in some persistent environment, notably
: mod_perl (or mod_parrot in the future.) When you have a virtual machine,
: you'll end up including modules at run time, because the main
: compilation phase becomes less important. Thus CHECK blocks become
: worthless, code-reusability-wise.

Possibly a CHECK block that is compiled after end of main compilation
should translate itself to a UNITCHECK.  But maybe it should be an error.

But it's also possible that CHECK should mean "unit check", and
there should be an explicit MAINCHECK for delegating checks to the
main compilation.  In that case, only in the main compilation would
CHECK and MAINCHECK mean the same thing.  (And since MAINCHECK is
explicitly requesting a check at the end of main, a late MAINCHECK
should probably be considered an error.  (But by that argument, a late
CHECK should probably fail under the current naming scheme.))

Anybody got opinions on the naming of these beasts?  Certainly *not*
renaming CHECK is more compatible with Perl 5.  And I kinda got fond
of UNITCHECK in the last hour or so.  :-)

Larry


Given the fact that use of these blocks are overall quite rare, and potentially very confusing to the casual perl hacker who encounters one of them, I propose a rather different tact:

BEGIN => EXECUTE_ON_PARSE
CHECK => EXECUTE_AFTER_COMPILE and EXECUTE_AFTER_UNIT_COMPILE
INIT => EXECUTE_INITIALIZATION
END => EXECUTE_ON_EXIT

This also has the advantage of being able to reserve all subs with name EXECUTE_.* for compiler/interpreter special sub like these, so we could add more of them come perl 6.8 w/o much issue.

-- Rod




Reply via email to