develooper Front page | perl.perl5.porters | Postings from March 2023

Re: Deprecation doesn't mean we have two release cycles beforethings break.

Thread Previous | Thread Next
From:
"Ruud H.G. van Tol" via perl5-porters
Date:
March 6, 2023 08:39
Subject:
Re: Deprecation doesn't mean we have two release cycles beforethings break.
Message ID:
459ae39f-5943-e9cf-1125-33ce3069b452@isolution.nl

On 2023-03-05 18:23, demerphq wrote:

> [...] I wonder if perhaps deprecation
> warnings should be automatically "warn once".

Then some things should only warn once per total test,
others once per test-phase, others once per
$$, __PACKAGE__ / __FILE__, __LINE__.

(just saying that likely needs some interesting instrumentation)

-- Ruud


For the in-process-level, I often use this:

sub warn_once {
     my ( undef, $c_fname, $c_line )= caller;

     my $key= join "\0",
         $$,
         $c_fname,
         $c_line,
         @_;  #TODO: unify timestamps?; md5()

     state %warn_once;
     $warn_once{ $key }++
         or warn @_,
             ( (@_ and $_[-1] =~ /\n\z/) ? () : " at $c_fname line 
$c_line. (warn_once)\n" );
}


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About