On Fri, Mar 21, 2003 at 01:11:04PM -0600, Dave Rolsky wrote:
> On Fri, 21 Mar 2003, fglock wrote:
> 
> > Dave Rolsky wrote:
> > > I suppose I could include a pure Perl solution.  What is your barrier to
> > > using XS?
> >
> > That's something I'd like too.
> >
> > I could test my code on Windows, without having to wait until someone
> > compiles it for me.
> 
> Ok, I'll implement this for the next release.  It's simple enough since
> all the code existed in Perl previously.

Having transparent failover is handy.

You can wrap the "bootstrap" call in an eval { }. Then you've got
a few choices, either put the perl versions of the XS subs at the
end after __DATA__ and add "use SelfLoader;", or do a require of a
separate module with the perl code. I'd suggest the later, it's
what the DBI uses to load DBI::PurePerl.

Another key issue is the need to automatically test both XS and
pure perl versions. The DBI has a cute trick for this. For every
t/*.t file the Makefile.PL writes a t/zz_*.t that just contains:

        #!perl -w
        $ENV{DBI_PUREPERL}=2;
        do 't/test-name-here.t' or warn $!;
        die if $@;
        exit 0

The env var triggers the DBI to not even try to bootstrap the XS
code but go straight to loading the pure-perl code.

Having this automated has caught countless would-be-bugs as the DBI
and it's test suite has evolved.

Tim.

Reply via email to