in reply to Re^3: Can I add methods to an existing object?
in thread Can I add methods to an existing object?

But both threw warnings that Log::Dispatch::warn is "used only once: possible typo...";
And both are the Right Way to alias a function. Warnings are hints, not laws.
  • Comment on Re^4: Can I add methods to an existing object?

Replies are listed 'Best First'.
Re^5: Can I add methods to an existing object?
by linuxer (Curate) on Apr 03, 2009 at 15:28 UTC
    And both are the Right Way to alias a function. Warnings are hints, not laws.

    I didn't write, that it's a wrong way. And I didn't write about warnings being laws. I like to get rid of warnings without writing no warnings;, so I mentioned another way which doesn't show a warning.

    Is it bad to look for ways to avoid warnings without writing no warnings;?

    sub foo::bar { my ( $self ) = shift; $self->foo(@_); }

    So, is that so much worse than aliasing the function?

    All in all, I I don't know how to handle your answer.
    What's your intention?
    Just information, that the aliasing was done right?
    Should I consider something else?

    Thanks in advance for your explanation.

      Is it bad to look for ways to avoid warnings without writing "no warnings?"
      Yes, when the only point of looking is to avoid warnings. When you find yourself thinking "I know what this code is doing, and I want it to do that, but 'use warnings' bitches at me," you should avoid "use warnings."

        I'd rather say "... you should use "no warnings xxxx" in a small block around that code". Apart from the "uninitialized" warning. That one is IMNSHO pointless and annoying and should be turned off everywhere.

        Ok, I see that point. Thank you.

      In addition to what educated_foo was saying: You can scope and limit the warnings too and generally should even if you know why you're turning them off to prevent stupid mistakes or assumptions which might bury bugs.

      { # some scoping block/sub no warnings "once"; # one time whatever... }