Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: 'Ambiguous call' diagnosis seems ambiguous

by chromatic (Archbishop)
on Aug 03, 2012 at 00:56 UTC ( #985133=note: print w/ replies, xml ) Need Help??


in reply to 'Ambiguous call' diagnosis seems ambiguous

Perl's tokenizer classifies some keywords as "weak keywords" such that you can override them with user-defined functions. (Calling them is another matter.) delete is a weak keyword and each is not. our is weak, but sub is not:

use strict; use warnings; sub each { warn 'main::each() was called' } sub delete { warn 'main::delete() was called' } sub dump { warn 'main::dump() was called' } sub chop { warn 'main::chop() was called' } sub our { warn 'main::our() was called' } my %person = ( name => 'Ken Takakura' ); while ( my ($key, $val) = each %person ) { print "$key: $val\n"; } &our( $person{name} ); delete $person{name}; chop $person{name}; dump( $person{name} );

I don't know how to make a list of weak and normal keywords without reading the source code (keywords.c or regen/keywords.pl).


Comment on Re: 'Ambiguous call' diagnosis seems ambiguous
Select or Download Code
Re^2: 'Ambiguous call' diagnosis seems ambiguous
by anazawa (Beadle) on Aug 03, 2012 at 01:45 UTC
    Thanks for your suggestion. Your code output the following:
    Ambiguous call resolved as CORE::each(), qualify as such or use & at a +mbiguous_calls.pl line 12. Ambiguous call resolved as CORE::chop(), qualify as such or use & at a +mbiguous_calls.pl line 18. dump() better written as CORE::dump() at ambiguous_calls.pl line 19. Ambiguous call resolved as CORE::dump(), qualify as such or use & at a +mbiguous_calls.pl line 19. name: Ken Takakura main::our() was called at ambiguous_calls.pl line 8. Use of uninitialized value $person{"name"} in scalar chop at ambiguous +_calls.pl line 18. Abort

    This result shows us that delete and our belong to "weak keywords", and each, chop and dump don't.

    The following was quoted from regen/keywords.pl:

    145: -chop 160: +delete 163: -dump 164: -each 261: +our

    Plus (+) signs maybe mean "weak".

    Your comment meant a lot to me :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2014-09-30 17:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (378 votes), past polls