This is a really good feature request. Unfortunately, short of what the module author has programmed, perl has no knowledge if the module has XS or Pure Perl (PP) variants and if the engine was loaded through fallback.
This example you bring up is compounded by the effect that they're packaged in the same distro and module, and it is all done internally. I'd patch it to follow the CPAN convention: DateSimple
, which requires DateSimple::PP
and recommends DateSimple::XS
. This is how Text::CSV
, and others do it. This method permits using the ::XS
constructor directly to force use of XS
and at the same time not even installing the pureperl variant. Alternatively, you can package them together -- this is what Template::Stash
does with Template::Stash::XS
. The first step to getting anything unified is getting the functionality ad-hoc.
This sort of thing could be easily done if the modules all pulled in a Moose::Role
that provided a few basic attributes _xs_class_name
, _pp_class_name
, and engine_override
. But, again, there is nothing as of now that even seeds a unified API to achieve this.