Subject: | Enhancement Request: has_module, a static alternative to can_use |
there's some modules that exist I'm phobic of actually loading in Makefile.PL.
For instance, I'm very glad Devel::Cover dosn't bootstrap its XS code while its sourcing, and instead bootstraps in `import`, or loading that *would* be a potentailly code-breaking thing to do.
So it makes sense to me that we have a way to statically determine if a module is installed, in the same way EUMM itself does, instead of simply loading the module into memory.
I'd probably propose something like
has_module("Foo")
has_module("Foo", "1.00") # 1 if Foo exists and $Foo::VERSION >= 1.000
has_module("Foo","<=","1.00") # 1 if Foo exists and $Foo::VERSION <= 1.00
Or something. That last one raises some logic issues that need to be nutted out, because somebody may want
- not has foo => no problem
- has foo > 1.00 => no problem
- has foo and foo <= 1.00 => problem
So the state map is .....
{ x_exists => 0/1 , x_version_range_satisfied => 0/1 }
Might be smart to split it into 2 functions.
if( has_module("Foo") && module_version("Foo") lt "1.00" ){ print "Error" }
if( has_module("Foo") && module_version("Foo') gt "1.00" ) { print "Standard Prereq detection OK" }
if ( !has_module("Foo") || module_version("Foo") gt "1.00" ) { "This is a satisfactory condition" } else {
print "Error"
}
Or something?
> module_version("Foo") lt "1.00"
These semantics are the only place I get really scared because it implies externally dealing with version.pm stuff.
So ideally it would be module_version("Foo","<=","1.00") # and you'd just transmute the <= and version bits into the right value internally and then use version.pm in whatever the right way is this week, as opposed to having everyone remember how that shit works.