Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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/

Replies are listed 'Best First'.
Re^2: 'Ambiguous call' diagnosis seems ambiguous
by anazawa (Scribe) 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 line 12. Ambiguous call resolved as CORE::chop(), qualify as such or use & at a line 18. dump() better written as CORE::dump() at line 19. Ambiguous call resolved as CORE::dump(), qualify as such or use & at a line 19. name: Ken Takakura main::our() was called at line 8. Use of uninitialized value $person{"name"} in scalar chop at ambiguous 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/

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

    Plus (+) signs maybe mean "weak".

    Your comment meant a lot to me :)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2016-09-27 02:19 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (493 votes). Check out past polls.