Overridable builtins

rafael on 2001-12-03T13:27:17

There's no end at learning about Perl.

Contrary to some common belief, (dunno how much common it is), it appears that if you want to test whether a function is overridable, the idiom

$overridable = defined prototype "CORE::$builtin";
does not work (at least with perl 5.6.1). Try with system or exec (on a recent perl). Their prototype is undefined, but they are overridable. And perlfunc/prototype never said it should be otherwise.

FWIW, this minimal code defines a function that gives the correct result :

use Inline C => <<'**END_C**';
I32 overridable(char *name) {
    return keyword(name,strlen(name)) < 0 ? 1 : 0;
}
**END_C**
Perhaps I will put this in a module. With a counterpart that tests if a function is overriden. If I have time.