Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Built-in Function Homonyms for Method Names Bad, Too?

by hv (Prior)
on Jan 27, 2006 at 00:16 UTC ( [id://525878]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://525878]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-29 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found