develooper Front page | perl.perl5.porters | Postings from May 2008

Re: bug or not? constants warn only once

Thread Previous | Thread Next
Aristotle Pagaltzis
May 5, 2008 10:00
Re: bug or not? constants warn only once
Message ID:
Hi Nick,

* Nicholas Clark <> [2008-04-26 19:45]:
> On Sat, Apr 26, 2008 at 01:51:21AM +0200, Aristotle Pagaltzis wrote:
> > Perl has gotten a lot slower over time; let’s not add more
> > bloat if there isn’t good, or indeed any, reason for it.
> (As an aside, do you have good, shareable benchmarks to
> demonstrate this?)

not on hand, but running any microbenchmark such as the Shootout
with 5.5, 5.6 and 5.8 should demonstrate it clearly. Note that I
pay the price gladly for the most part, as much of that slowdown
was the price for more correctness or additional features. (Eg.
the regex engine was almost twice as fast before the bookkeeping
was added to detect exponential-time blowups of bad patterns.)

> Do the appended tests codify the behaviour we desire? Anything
> I've missed that would be necessary to nail down this
> behaviour?

Yes, although I found them rather hard to read.


> sub warnings {
>   my ($got, $expect, $todo) = @_;
>   local $Test::Builder::Level = $Test::Builder::Level + 1;
>   local $TODO = $todo;
>   if ($expect) {
>     is(scalar @$got, 1);
>     like($got->[0], $expect);
>   } else {
>     is(scalar @$got, 0);
>     diag $_ foreach @$got;
>   }
> }

if you change the framed part to this:

    @$got != 1
        ? is(scalar @$got, 1, 'expected the right number of warnings')
        : like($got->[0], $expect, 'expected the right warning');

then the number tests becomes invariant and you can set a plan.

I’ve also taken some time to rewrite the tests in a way that
feels more straightforward to me, so that the code reads closer
to its intent. The `addit` and `xorit` functions were a bit too
much abstraction and the `warnings` test utility had too little,
so I refactored the code to move responsibilities around a

I am, however, not sure about why you did some things the way you
did them, so please check that the resulting test still tests the
same things as before.

For reference, I attach the slightly modified version of your
tests that I used to verify that my refactors result in exactly
identical output. For comparison I ran them with

 diff -U2000 \
 <(perl 2>&1 | sed 's!\.old!!g; s!at t\.pl line [0-9]\+!!g') \
 <(perl     2>&1 | sed '            s!at t\.pl line [0-9]\+!!g')

*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
#Aristotle Pagaltzis // <>

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About