Steffen Mueller wrote:
John Peacock schrieb:
David Golden wrote:
(Though technically, it really ought to check that the ref equals
"Module::Build::Version").
No, that would be wrong too. Never test a ref() against a specific
object
class, since it paints you into a corner with inheritance. You really
have to
do isa() if you want to test that way...
Since isa() can have a few surprises also, I tend to use _INSTANCE($obj,
'Class') from Adam's small and useful Params::Util module. It's
guaranteed to work as advertised. isa() might be overridden if called as
a function (bad) or fail if called as a method on a non-object.
But since this is Module::Build, we don't want to go around adding
dependencies like that, even if they are useful. (Though cut-and-paste
is a possibility.)
In this particular case, the semantics of how Module::Build::Version are
used by Module::Build are pretty complex. Someone can't just swap out
M::B::Version without subclassing M::B::ModuleInfo and then M::B::Base
to use the subclass not only for module information but for any version
comparison (because it upgrades everything to M::B::V unless is
UNIVERSAL::isa M::B::V already).
Given all that, I felt the technical check was to just make sure the ref
is equal to M::B::V. I wasn't ready to suggest adding any subclass
semantics, since they really aren't there already. To use John
Peacock's metaphor, I think we're painted into the corner already. :-)
As it is, Ken's solution is even better that my first suggestion to just
call the stringify() if the version parameter was true -- it will now
just appends the version parameter to the empty string. So the semantic
is that whatever M::B has as the version must be a string or must
stringify (via overload) to the "right" version string for META.yml.
Regards,
David Golden