On Sun, May 08, 2005 at 02:39:03PM +1000, Andrew Savige wrote: : A crude hack sometimes used by gung ho p5 testers is to redefine : perl built-in functions. For example: : : BEGIN { : *CORE::GLOBAL::read = sub (*\$$;$) { return undef }; : } : : to test read failures (and so boost your Devel::Cover score :-). : This technique is not very convenient (must be in a BEGIN block). : Moreover, some p5 functions (e.g. print) cannot be overridden.
It's not clear that Perl 6 has *any* built-in functions in the sense that Perl 5 does. All global functions live in the * namespace, which is the last place Perl looks. Any lexical or package scope will override a * function. You can also do partial overrides of multimethods when you have enough type information. You also have control of the Perl grammar so that, even if something is more "built-in" than a global function, you can change the grammar rule that parses it. On a small scale, this means you can define macros in various grammatical categories. : I was wondering how/if p6 will support the overriding of built-in : functions (I imagine QA would be the main use for this). Absolutely everything is overridable in Perl 6, except the fact that the program is parsed as Standard Perl up till the first declaration (which might, of course, occur before the program file in a switch.) Larry