develooper Front page | perl.perl5.porters | Postings from July 2011


Thread Previous | Thread Next
Father Chrysostomos
July 3, 2011 13:14
Message ID:

On Jun 20, 2011, at 3:25 AM, John Peacock wrote:

> On 06/19/2011 11:41 PM, Father Chrysostomos wrote:
>> I’ve come up with a simple way to fix the incompatibility between UNIVERSAL::VERSION and stop UNIVERSAL::VERSION from parsing the version if called with no arguments. When called simply as package->VERSION, the purpose is to retrieve the v...bersion number, so why is VERSION trying to parse it anyway? It didn’t in 5.8.
> Because version objects were introduced into the core in 5.10.0.  UNIVERSAL::VERSION always did double duty (in that with a parameter it would do a comparison and without would return the package $VERSION), so when version objects were added, it only made sense to upgrade the scalar to a version object so it could be used in a comparison.  

But such should not be necessary if no comparison is to take place.

> The fact that it returns the stringified form, rather than a version object directly, was a matter of some discussion.
> What bug(s) are you trying to fix?  I see nothing in rt about and UNIVERSAL::VERSION, but then maybe my searching skills have atrophied.  The real problem is is excessively clever (not) and should be deprecated in favor of does useful things that doesn’t do. (Each module in turn considers that a feature.) sets $VERSION to "-1, set by" in some cases, so it knows the package has been loaded. Some have expressed astonishment on learning that, but no-one has suggested a better way to detect whether a package is loaded. (You can’t just check the existence of the stash, as merely mentioning the package in a fully qualified sub call autovivifies it during compilation.)

>> (This also resolves a CPAN ticket for another VERSION problem.)
> Citation please?

I don’t remember the bug number off hand, but this is the issue:

Code like this used to work in 5.8.x:

$VERSION = "3alpha";

  my $version = shift->SUPER::VERSION;
  if(@_) {
     .... do custom comparison ....
     die $message if $too_old

Such code, which is just using SUPER::VERSION to fetch the version number (since it’s clea[rn]er that ‘do{no strict "refs"; ${(length ref($_[0]) ? ref $_[0] : $_[0])."::VERSION"}}’), and which in 5.8.x is a perfectly acceptable use of UNIVERSAL::VERSION, broke in 5.10.0.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About