[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: possible ":method" bug/misfeature



On Wed, Jan 19, 2000 at 09:41:26AM -0700, Tom Christiansen wrote:
> >tc> Here's the issue: I fail to see *why* it suppresses that
> >tc> warning, as it still applies.
> 
> >No, it doesn't.  You said, "I'm only planning to use this as a
> >method.  I know it's not necessarily available as a first-class
> >sub name.  Shut up about that."  You got what you asked for.
> 
> >This warning suppression per-subroutine is specifically so that
> >modules can have methods named after builtins, and yet still
> >invoke the builtins internally without having to replace all
> >instances of (e.g.) send() with CORE::send(), which looks ugly,
> >just to shut up that warning for known subroutines which we never
> >intended to have supplant the builtin.  The warning and the
> >renaming are a real pain in the ass, and an affront to module
> >writers who never considered the usage just described to be
> >ambiguous (since it never was).
> 
> There's something very strange here, then.  I believe that the
> warning in question *never* triggers on method calls that conflict
> with built-ins, irrespective of a ":method" attribute.  Witness:
> 
>     sub oct { 042 }
>     $n = main::->oct(9999);
>     print "n is $n\n";
> 
>     % perl -w /tmp/testmeth
>     n is 34
> 
> One or both of us seem to be missing something here.
> 

If I understand the situation, the warning is not for method calls that
conflict with built-ins; it's for built-ins that conflict with user-defined
subroutines.

sub oct { 042 }
$n = oct(9999);   # <-- built-in or user-defined sub?  better warn user
print "n is $n\n";

sub oct :method { 042 }
$n = oct(9999);   # <-- not a method call; must be the built-in.  no warning
print "n is $n\n";

sub oct { 042 }
$n = main::->oct(9999);   # <-- method call, of course.  no warning
print "n is $n\n";

sub oct :method { 042 }
$n = main::->oct(9999);   # <-- method call, again.  no warning
print "n is $n\n";


The :method attribute says "all ambiguous calls are definitely for the
built-in."


Ronald


References to:
Tom Christiansen <tchrist@chthon.perl.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]