Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

robin (1821)

robin
  (email not shown publicly)
about:blank

Journal of robin (1821)

Tuesday August 28, 2001
05:16 AM

bits & pieces

[ #714 ]

I've produced new versions of both Algorithm::PermuteInPlace and Algorithm::FastPermute.

They both had nasty bugs that would cause them to crash, and PermuteInPlace wouldn't work at all on any Perl version less than 5.7. Ah, the joys of the bleeding edge...

FastPermute uses a callback technique which I essentially stole from the first and reduce routines in List::Util. While I was testing FastPermute I noticed that exception handling doesn't work inside the callback. So code like this:

  permute { eval {die}; print "Got here!\n" } @array

will not continue past the die, even though the exception should have been caught. There followed a quick self-taught crash course in perl's exception handling mechanism. It's based around setjmp/longjmp, and like most of Perl's internals is simultaneously ingenious and baroque. When there's an exception, control immediately passes to the exception handler, whose responsibility it then is to continue if appropriate. Anyway after an intense few hours, FastPermute now deals politely and properly with exceptions. (Maybe I should fix up List::Util, now I've worked out how to do it.)

I'm still not quite sure whether the exception handling code, as it stands, makes FastPermute significantly slower. It now looks possible that it doesn't really; and that my comments in the README are misinformed.