in reply to Re: Built-in Function Homonyms for Method Names Bad, Too?
in thread Built-in Function Homonyms for Method Names Bad, Too?
The gotcha is that any attempts to use the builtins inside your module: return, split, delete, will result in calls to the subs in your package, not the builtins [...]
I can't find a test case for this behaviour - do you have an example?
There is a distinction between strong and weak keywords 1 which shows a slight difference in behaviour. With a strong keyword, the keyword overrides the subroutine:
zen% perl -wle 'my %hash; sub delete { die "not this one" } delete($ +hash{key})' zen%
A weak keyword gives a warning, but is still preferred to the subroutine:
zen% perl -wle 'sub bless { die "not this one" } my $a=bless({});' Ambiguous call resolved as CORE::bless(), qualify as such or use & a +t -e line 1. zen%
I'm sure I'm missing something that would justify your comment, but I can't offhand think what it is.
Hugo
1 The distinction between weak and strong keywords is probably not well documented; in older perls I think the only way to check was to examine the C code in toke.c, but happily perl-5.8.7 now bundle a script perl_keyword.pl to generate the code, which has clear lists of weak (@neg) and strong (@pos) keywords at the start of the script.
|
|---|