Closed p5pRT closed 13 years ago
[So\, how long till the perlbug alias is fixed?]
From perldata:
A literal of the form `v1.20.300.4000' is parsed as a string composed of characters with the specified ordinals. .... Such literals are accepted by both `require' and `use' for doing a version check.
This is not true\, however. Witness:
% perl -MIO::File -le 'print IO::File::->VERSION 1.08
% perl -e 'use IO::File 1.08'
% perl -e 'use IO::File v1.08' Octal number in vector unsupported at -e line 1\, at end of line BEGIN not safe after errors--compilation aborted at -e line 1.
# vector? qu'est-ce que c'est qu'un vector? # did I vec() something for select()?
% perl -e 'use IO::File 1.8' IO::File version 1.8 required--this is only version 1.08 at -e line 1. BEGIN failed--compilation aborted at -e line 1.
% perl -e 'use IO::File v1.8'
% perl -e 'use IO::File 1.8.2'
% perl -e 'use IO::File v1.8.2'
% perl -e 'use IO::File 1.9.2.20'
% perl -e 'use IO::File v1.9.2.20'
% perl -e 'use IO::File 1.9.9'
% perl -e 'use IO::File 1.9.9999.9999999'
% perl -e 'use IO::File v1.9.9'
% perl -e 'use IO::File v1.9.9999.9999999'
### Ick ick ick! Something sure smells pretty icthy around here.
# And here's some naive stuff. Remember: version were always numbers # before. So one expects numbers to continue to work. But they don't. # And produce very odd msgs.
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION > 1.8' 0
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION > v1.8' 1
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION \< 1.8' 1
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION \< v1.8' 0
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION == 1.08' 1
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION == v1.08' Octal number in vector unsupported at -e line 1\, at end of line Execution of -e aborted due to compilation errors.
# octal huh?
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION == v1.80' Octal number in vector unsupported at -e line 1\, at end of line Execution of -e aborted due to compilation errors.
% perl -MIO::File -we 'printf "%d\n"\, IO::File::->VERSION == v1.80' Argument "^AP" isn't numeric in numeric eq (==) at -e line 1. 0
# That's disgusting. Run it through uncontrol!
--tom
Tom Christiansen \tchrist@​perl\.com writes:
# And here's some naive stuff. Remember: version were always numbers # before.
No they were not - at least if you had any XS code. XS_VERSION_BOOTCHECK did (and does!) a string compare:
# define XS_VERSION_BOOTCHECK \ ... if (tmpsv && (!SvOK(tmpsv) || strNE(XS_VERSION\, SvPV(tmpsv\, n_a)))) \ ... -- Nick Ing-Simmons \nik@​tiuk\.ti\.com Via\, but not speaking for: Texas Instruments Ltd.
[tchrist@chthon.perl.com - Tue Mar 28 03:38:58 2000]:
From perldata:
A literal of the form `v1.20.300.4000' is parsed as a string composed of characters with the specified ordinals. .... Such literals are accepted by both `require' and `use' for doing a version check.
This is not true\, however. Witness:
% perl -MIO::File -le 'print IO::File::->VERSION 1.08
% perl -e 'use IO::File 1.08'
% perl -e 'use IO::File v1.08' Octal number in vector unsupported at -e line 1\, at end of line BEGIN not safe after errors--compilation aborted at -e line 1.
# vector? qu'est-ce que c'est qu'un vector? # did I vec() something for select()?
% perl -e 'use IO::File 1.8' IO::File version 1.8 required--this is only version 1.08 at -e line 1. BEGIN failed--compilation aborted at -e line 1.
% perl -e 'use IO::File v1.8'
% perl -e 'use IO::File 1.8.2'
% perl -e 'use IO::File v1.8.2'
% perl -e 'use IO::File 1.9.2.20'
% perl -e 'use IO::File v1.9.2.20'
% perl -e 'use IO::File 1.9.9'
% perl -e 'use IO::File 1.9.9999.9999999'
% perl -e 'use IO::File v1.9.9'
% perl -e 'use IO::File v1.9.9999.9999999'
### Ick ick ick! Something sure smells pretty icthy around here.
# And here's some naive stuff. Remember: version were always numbers # before. So one expects numbers to continue to work. But they don't. # And produce very odd msgs.
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION > 1.8' 0
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION > v1.8' 1
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION \< 1.8' 1
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION \< v1.8' 0
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION == 1.08' 1
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION == v1.08' Octal number in vector unsupported at -e line 1\, at end of line Execution of -e aborted due to compilation errors.
# octal huh?
% perl -MIO::File -e 'printf "%d\n"\, IO::File::->VERSION == v1.80' Octal number in vector unsupported at -e line 1\, at end of line Execution of -e aborted due to compilation errors.
% perl -MIO::File -we 'printf "%d\n"\, IO::File::->VERSION == v1.80' Argument "^AP" isn't numeric in numeric eq (==) at -e line 1. 0
# That's disgusting. Run it through uncontrol!
v1.2.3 style version strings are being "phased out" and should be replaced by the various options presented by version.pm.
All the above now works in 5.8.6 with the exception of the final "Argument "^AP" isn't numeric" warning which is still there. As version strings are going bye-bye will that ever be fixed?
Michael G Schwern via RT wrote:
v1.2.3 style version strings are being "phased out" and should be replaced by the various options presented by version.pm.
Well\, no\, not exactly. v1.2.3 versions are likely to be the preferred format for Perl6 (AIUI)\, but the leading 'v' won't be a v-string any longer but rather a fullblown version number. It's true that the version.pm module will permit compatibility for older Perl's\, but the following are completely equivalent (under v5.9.3+):
package oldstyle; use version; our $VERSION = version->new(v1.2.3);
package newtyle; our $VERSION = v1.2.3;
OK\, I'm fibbing a little in that the first package will have a version object and the second will not (although I have a patch to do so)\, but both of them will emerge from UNIVERSAL::VERSION completely identically\, i.e. as 1.002003). See below for why that distinction is important.
All the above now works in 5.8.6 with the exception of the final "Argument "^AP" isn't numeric" warning which is still there. As version strings are going bye-bye will that ever be fixed?
It shouldn't be fixed\, because the naive tests Tom was making in the second half of the bug were based on a flawed understanding of how the UNIVERSAL::VERSION sub operated then or now. When called as a class method like IO::File::->VERSION\, UNIVERSAL::VERSION merely returns the contents of the package $VERSION scalar. As such\, any special handling due to v-string\, etc\, doesn't happen at all. And so there is no way that a bare == comparison will "know" anything about how to handle version comparisons vs. v-strings.
The only way to see whether the v-string versions are handled properly in Perl 5.8.1+ is to 'use package v1' (and hence why all of the first half of the bug report now work fine). It is not currently possible to compare a version number to a bare v-string and unless I make $VERSION a magical scalar to automatically upgrade to version objects (a patch I currently have working\, BTW)\, it won't ever be possible in the general case.
With the patch I have to automatically upgrade the package $VERSION scalar to a version object\, the following becomes true:
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'print ref $IO::File::VERSION' version
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'printf "%d\n"\, $IO::File::VERSION == v1.120' 1
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'printf "%d\n"\, $IO::File::VERSION == v1.121' 0
but when called as a package method\, UNIVERSAL::VERSION returns the *numified* representation of the underlying version object\, not the version object itself\, so this will still warn:
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'printf "%d\n"\, IO::File::->VERSION == v1.120' Argument "^Ax" isn't numeric in numeric eq (==) at -e line 1. 0
I have delayed closing this ticket mostly through inertia. With this explanation appended\, it can now be safely closed I think.
John
-- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4720 Boston Way Lanham\, MD 20706 301-459-3366 x.5010 fax 301-429-5747
@cpansprout - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#2741 (status was 'resolved')
Searchable as RT2741$