develooper Front page | perl.perl5.porters | Postings from February 2000

Re: tupping

Thread Next
From:
Gurusamy Sarathy
Date:
February 21, 2000 13:28
Subject:
Re: tupping
Message ID:
200002212129.NAA11551@maul.activestate.com
Cc-ed to p5p.

On Mon, 21 Feb 2000 08:55:41 PST, Larry Wall wrote:
>tchrist@perl.com writes:
>: Was there ever any sort of closure on whether the term "version
>: tuple" would be replaced by something like "version string"?  (I'm
>: looking at $PERL_VERSION_TUPLE sitting there in English.pm.)
>
>We should lose the _TUPLE, but I'm not sure how.  Some ideas:
>
>    $PERL_VERSION_DOTS
>    $PERL_REVISION
>    $PERL_DOTVER
>    $PERL_VER
>
>Or how about $PERL_VERSION?  Just steal the name, and call the old one
>$PERL_VERSION_DEPRECATED.  Even if $^V is only a string, it'll generally
>do the reasonable thing for old code, since "5.6.0" > 5.005_04.  And it'll
>even give them a warning.  :-)

OK, $PERL_VERSION now points to $^V.  $^V is (still) dual valued, so it
compares fine against a number without warnings:

    % ./perl -Ilib -MEnglish -lwe 'print "yeah" if $PERL_VERSION > 5.005_50'
    yeah

The potential incompatibility only arises if they *interpolated* $PERL_VERSION
in a string somewhere, but I think that may only have relatively minor
impact.  It is noted in perldelta as such.


Sarathy
gsar@ActiveState.com
-----------------------------------8<-----------------------------------
Change 5186 by gsar@auger on 2000/02/21 21:10:26

	remove dual-valueness of v-strings (i.e., they are pure strings
	now); avoid the word "tuple" to describe strings represented as
	character ordinals; usurp $PERL_VERSION for $^V as suggested by
	Larry, deprecate $] ; adjust the documentation and testsuite
	accordingly

Affected files ...

... //depot/perl/MANIFEST#238 edit
... //depot/perl/lib/English.pm#15 edit
... //depot/perl/op.c#264 edit
... //depot/perl/pod/perldelta.pod#157 edit
... //depot/perl/pod/perlfunc.pod#150 edit
... //depot/perl/pod/perlop.pod#56 edit
... //depot/perl/pod/perlvar.pod#49 edit
... //depot/perl/t/comp/require.t#10 edit
... //depot/perl/t/op/ver.t#4 edit
... //depot/perl/toke.c#202 edit

Differences ...

==== //depot/perl/MANIFEST#238 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST.~1~	Mon Feb 21 13:10:31 2000
+++ perl/MANIFEST	Mon Feb 21 13:10:31 2000
@@ -1390,7 +1390,7 @@
 t/op/universal.t	See if UNIVERSAL class works
 t/op/unshift.t		See if unshift works
 t/op/vec.t		See if vectors work
-t/op/ver.t		See if version tuples work
+t/op/ver.t		See if v-strings and the %v format flag work
 t/op/wantarray.t	See if wantarray works
 t/op/write.t		See if write works
 t/pod/emptycmd.t	Test empty pod directives

==== //depot/perl/lib/English.pm#15 (text) ====
Index: perl/lib/English.pm
--- perl/lib/English.pm.~1~	Mon Feb 21 13:10:31 2000
+++ perl/lib/English.pm	Mon Feb 21 13:10:31 2000
@@ -87,7 +87,6 @@
 	*EGID
 	*PROGRAM_NAME
 	*PERL_VERSION
-	*PERL_VERSION_TUPLE
 	*ACCUMULATOR
 	*DEBUGGING
 	*SYSTEM_FD_MAX
@@ -167,8 +166,7 @@
 
 # Internals.
 
-	*PERL_VERSION				= *]	;
-	*PERL_VERSION_TUPLE			= *^V	;
+	*PERL_VERSION				= *^V	;
 	*ACCUMULATOR				= *^A	;
 	*COMPILING				= *^C	;
 	*DEBUGGING				= *^D	;
@@ -187,5 +185,6 @@
 #	*ARRAY_BASE				= *[	;
 #	*OFMT					= *#	;
 #	*MULTILINE_MATCHING			= **	;
+#	*OLD_PERL_VERSION			= *]	;
 
 1;

==== //depot/perl/op.c#264 (text) ====
Index: perl/op.c
--- perl/op.c.~1~	Mon Feb 21 13:10:31 2000
+++ perl/op.c	Mon Feb 21 13:10:31 2000
@@ -3109,14 +3109,14 @@
     if (version != Nullop) {
 	SV *vesv = ((SVOP*)version)->op_sv;
 
-	if (arg == Nullop && !SvNIOK(vesv)) {
+	if (arg == Nullop && !SvNIOKp(vesv)) {
 	    arg = version;
 	}
 	else {
 	    OP *pack;
 	    SV *meth;
 
-	    if (version->op_type != OP_CONST || !SvNIOK(vesv))
+	    if (version->op_type != OP_CONST || !SvNIOKp(vesv))
 		Perl_croak(aTHX_ "Version number must be constant number");
 
 	    /* Make copy of id so we don't free it twice */
@@ -3137,7 +3137,7 @@
     /* Fake up an import/unimport */
     if (arg && arg->op_type == OP_STUB)
 	imop = arg;		/* no import on explicit () */
-    else if (SvNIOK(((SVOP*)id)->op_sv)) {
+    else if (SvNIOKp(((SVOP*)id)->op_sv)) {
 	imop = Nullop;		/* use 5.0; */
     }
     else {

==== //depot/perl/pod/perldelta.pod#157 (text) ====
Index: perl/pod/perldelta.pod
--- perl/pod/perldelta.pod.~1~	Mon Feb 21 13:10:31 2000
+++ perl/pod/perldelta.pod	Mon Feb 21 13:10:31 2000
@@ -57,6 +57,33 @@
 
 See L<perldata>.
 
+=head2 Perl's version numbering has changed
+
+Beginning with Perl version 5.6, the version number convention has been
+changed to a "dotted integer" scheme that is more commonly found in open
+source projects.
+
+Maintenance versions of v5.6.0 will be released as v5.6.1, v5.6.2 etc.
+The next development series following v5.6 will be numbered v5.7.x,
+beginning with v5.7.0, and the next major production release following
+v5.6 will be v5.8.
+
+The English module now sets $PERL_VERSION to $^V (a string value) rather
+than C<$]> (a numeric value).  (This is a potential incompatibility.
+Send us a report via perlbug if you are affected by this.)
+
+The v1.2.3 syntax is also now legal in Perl.
+See L<Support for strings represented as a vector of ordinals> for more on that.
+
+To cope with the new versioning system's use of at least three significant
+digits for each version component, the method used for incrementing the
+subversion number has also changed slightly.  We assume that versions older
+than v5.6 have been incrementing the subversion component in multiples of
+10.  Versions after v5.6.0 will increment them by 1.  Thus, using the new
+notation, 5.005_03 is the same as v5.5.30, and the first maintenance
+version following v5.6.0 will be v5.6.1, which amounts to a floating point
+value of 5.006_001).
+
 =item Possibly changed pseudo-random number generator
 
 In 5.005_0x and earlier, perl's rand() function used the C library
@@ -286,29 +313,6 @@
 interpreter threads).  C<use Thread;> continues to be available when you
 ask for -Duse5005threads, bugs and all.
 
-=head2 Perl's version numbering has changed
-
-Beginning with Perl version 5.6, the version number convention has been
-changed to a "dotted tuple" scheme that is more commonly found in open
-source projects.
-
-Maintenance versions of v5.6.0 will be released as v5.6.1, v5.6.2 etc.
-The next development series following v5.6 will be numbered v5.7.x,
-beginning with v5.7.0, and the next major production release following
-v5.6 will be v5.8.
-
-The v1.2.3 syntax is also now legal in Perl.  See L<Support for version tuples>
-for more on that.
-
-To cope with the new versioning system's use of at least three significant
-digits for each version component, the method used for incrementing the
-subversion number has also changed slightly.  We assume that versions older
-than v5.6 have been incrementing the subversion component in multiples of
-10.  Versions after v5.6 will increment them by 1.  Thus, using the new
-notation, 5.005_03 is the same as v5.5.30, and the first maintenance
-version following v5.6 will be v5.6.1, which amounts to a floating point
-value of 5.006_001).
-
 =head2 New Configure flags
 
 The following new flags may be enabled on the Configure command line
@@ -455,39 +459,43 @@
 the opportunity to introduce typing and other attributes for such
 variables.  See L<perlfunc/our>.
 
-=head2 Support for version tuples
+=head2 Support for strings represented as a vector of ordinals
 
-Literals of the form v1.2.3.4 are now parsed as the utf8 string
-C<"\x{1}\x{2}\x{3}\x{4}">.  This allows comparing version numbers using
-regular string comparison operators C<eq>, C<ne>, C<lt>, C<gt> etc.
+Literals of the form v1.2.3.4 are now parsed as a string comprised of
+of characters with the specified ordinals.  This is an alternative, more
+readable way to construct (possibly unicode) strings instead of
+interpolating characters, as in C<"\x{1}\x{2}\x{3}\x{4}">.
 
-These "dotted tuples" are dual-valued.  They are both strings of utf8
-characters, and floating point numbers.  Thus v1.2.3.4 has the string
-value C<"\x{1}\x{2}\x{3}\x{4}"> and the numeric value 1.002_003_004.
-As another example, v5.5.640 has the string value C<"\x{5}\x{5}\x{280}">
-(remember 280 hexadecimal is 640 decimal) and the numeric value
-5.005_64.
+Strings written in this form are also useful to represent version "numbers".
+It is easy to compare such version "numbers" (which are really just plain
+strings) using any of the usual string comparison operators C<eq>, C<ne>,
+C<lt>, C<gt>, etc., or perform bitwise string operations on them using C<|>,
+C<&>, etc.
 
 In conjunction with the new C<$^V> magic variable (which contains
-the perl version in this format), such literals can be used to
-check if you're running a particular version of Perl.
+the perl version as a string), such literals can be used as a readable way
+to check if you're running a particular version of Perl:
 
+    # this will parse in older versions of Perl also
     if ($^V and $^V gt v5.5.640) {
-        # new style version numbers are supported
+        # new features supported
     }
 
-C<require> and C<use> also support such literals:
+C<require> and C<use> also have some special magic to support such literals.
+They will be interpreted as a version rather than as a module name:
 
     require v5.6.0;		# croak if $^V lt v5.6.0
     use v5.6.0;			# same, but croaks at compile-time
 
-C<sprintf> and C<printf> support the Perl-specific format flag C<%v>
+Also, C<sprintf> and C<printf> support the Perl-specific format flag C<%v>
 to print ordinals of characters in arbitrary strings:
 
     printf "v%vd", $^V;		# prints current version, such as "v5.5.650"
     printf "%*vX", ":", $addr;	# formats IPv6 address
     printf "%*vb", "", $bits;	# displays bitstring as contiguous 0's and 1's
 
+See L<perlop/"Strings of Character"> for additional information.
+
 =head2 Weak references
 
 WARNING: This is an experimental feature.
@@ -852,9 +860,12 @@
 
 =head2 New variable $^V contains Perl version in v5.6.0 format
 
-C<$^V> contains the Perl version number as a version tuple that
-can be used in string or numeric comparisons.  See
-C<Support for version tuples> for an example.
+C<$^V> contains the Perl version number as a string comprised of
+characters whose ordinals match the version numbers, so that it may
+be used in string comparisons.
+
+See C<Support for strings represented as a vector of ordinals> for an
+example.
 
 =head2 Optional Y2K warnings
 
@@ -1389,6 +1400,11 @@
 The Devel::Peek module provides access to the internal representation
 of Perl variables and data.  It is a data debugging tool for the XS programmer.
 
+=item English
+
+$PERL_VERSION now stands for C<$^V> (a string value) rather than for C<$]>
+(a numeric value).
+
 =item ExtUtils::MakeMaker
 
 change#4135, also needs docs in module pod

==== //depot/perl/pod/perlfunc.pod#150 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod.~1~	Mon Feb 21 13:10:31 2000
+++ perl/pod/perlfunc.pod	Mon Feb 21 13:10:31 2000
@@ -3549,9 +3549,17 @@
 =item require
 
 Demands some semantics specified by EXPR, or by C<$_> if EXPR is not
-supplied.  If a version number or tuple is specified, or if EXPR is
-numeric, demands that the current version of Perl
-(C<$^V> or C<$]> or $PERL_VERSION) be equal or greater than EXPR.
+supplied.
+
+If a VERSION is specified as a literal of the form v5.6.0,
+demands that the current version of Perl (C<$^V> or $PERL_VERSION) be
+at least as recent as that version, at run time.  (For compatibility
+with older versions of Perl, a numeric argument will also be interpreted
+as VERSION.)  Compare with L</use>, which can do a similar check at
+compile time.
+
+    require v5.6.0;	# run time version check
+    require 5.005_03;	# same, number still supported for compatibility
 
 Otherwise, demands that a library file be included if it hasn't already
 been included.  The file is included via the do-FILE mechanism, which is
@@ -5247,13 +5255,17 @@
 
 except that Module I<must> be a bareword.
 
-If the first argument to C<use> is a number or a version tuple, it is
-treated as a version instead of a module name.  If the version
-of the Perl interpreter is less than VERSION, then an error message
-is printed and Perl exits immediately.
+VERSION, which can be specified as a literal of the form v5.6.0, demands
+that the current version of Perl (C<$^V> or $PERL_VERSION) be at least
+as recent as that version.  (For compatibility with older versions of Perl,
+a numeric literal will also be interpreted as VERSION.)  If the version
+of the running Perl interpreter is less than VERSION, then an error
+message is printed and Perl exits immediately without attempting to
+parse the rest of the file.  Compare with L</require>, which can do a
+similar check at run time.
 
-    use 5.005_03;	# version number
-    use v5.6.0;		# version tuple
+    use v5.6.0;		# compile time version check
+    use 5.005_03;	# same, number still supported for compatibility
 
 This is often useful if you need to check the current Perl version before
 C<use>ing library modules that have changed in incompatible ways from
@@ -5280,7 +5292,7 @@
 If the VERSION argument is present between Module and LIST, then the
 C<use> will call the VERSION method in class Module with the given
 version as an argument.  The default VERSION method, inherited from
-the Universal class, croaks if the given version is larger than the
+the UNIVERSAL class, croaks if the given version is larger than the
 value of the variable C<$Module::VERSION>. 
 
 Again, there is a distinction between omitting LIST (C<import> called

==== //depot/perl/pod/perlop.pod#56 (text) ====
Index: perl/pod/perlop.pod
--- perl/pod/perlop.pod.~1~	Mon Feb 21 13:10:31 2000
+++ perl/pod/perlop.pod	Mon Feb 21 13:10:31 2000
@@ -1802,17 +1802,18 @@
 See L<perlfunc/vec> for information on how to manipulate individual bits
 in a bit vector.
 
-=head2 Version tuples
+=head2 Strings of Character
 
-A literal of the form C<v1.20.300.4000> is parsed as a dual-valued quantity.
-It has the string value of C<"\x{1}\x{14}\x{12c}\x{fa0}"> (i.e., a UTF-8
-string) and a numeric value of C<1 + 20/1000 + 300/1000000 + 4000/1000000000>.
-This is useful for representing Unicode strings, and for comparing version
-numbers using the string comparison operators, C<cmp>, C<gt>, C<lt> etc.
+A literal of the form C<v1.20.300.4000> is parsed as a string comprised
+of characters with the specified ordinals.  This provides an alternative,
+more readable way to construct strings, rather than use the somewhat less
+readable interpolation form C<"\x{1}\x{14}\x{12c}\x{fa0}">.  This is useful
+for representing Unicode strings, and for comparing version "numbers"
+using the string comparison operators, C<cmp>, C<gt>, C<lt> etc.
 
-Such "version tuples" or "vectors" are accepted by both C<require> and
-C<use>.  The C<$^V> variable contains the running Perl interpreter's
-version in this format.  See L<perlvar/$^V>.
+Such literals are accepted by both C<require> and C<use> for doing a version
+check.  The C<$^V> special variable also contains the running Perl
+interpreter's version in this form.  See L<perlvar/$^V>.
 
 =head2 Integer Arithmetic
 

==== //depot/perl/pod/perlvar.pod#49 (text) ====
Index: perl/pod/perlvar.pod
--- perl/pod/perlvar.pod.~1~	Mon Feb 21 13:10:31 2000
+++ perl/pod/perlvar.pod	Mon Feb 21 13:10:31 2000
@@ -699,8 +699,6 @@
 directive, and cannot influence the behavior of any other file.
 Its use is highly discouraged.
 
-=item $PERL_VERSION
-
 =item $]
 
 The version + patchlevel / 1000 of the Perl interpreter.  This variable
@@ -713,7 +711,10 @@
 See also the documentation of C<use VERSION> and C<require VERSION>
 for a convenient way to fail if the running Perl interpreter is too old.
 
-See C<$^V> for a more modern representation of the Perl version.
+The use of this variable is deprecated.  The floating point representation
+can sometimes lead to inaccurate numeric comparisons.  See C<$^V> for a
+more modern representation of the Perl version that allows accurate string
+comparisons.
 
 =item $COMPILING
 
@@ -905,24 +906,23 @@
 epoch (beginning of 1970).  The values returned by the B<-M>, B<-A>,
 and B<-C> filetests are based on this value.
 
-=item $PERL_VERSION_TUPLE
+=item $PERL_VERSION
 
 =item $^V
 
 The revision, version, and subversion of the Perl interpreter, represented
-as a "version tuple".  Version tuples have both a numeric value and a
-string value.  The numeric value is a floating point number that amounts
-to revision + version/1000 + subversion/1000000, and the string value
-is made of characters possibly in the UTF-8 range:
-C<chr($revision) . chr($version) . chr($subversion)>.
+as a string comprised of characters with those ordinals.  Thus in Perl v5.6.0
+it equals C<chr(5) . chr(6) . chr(0)> and will return true for
+C<$^V eq v5.6.0>.  Note that the characters in this string value can
+potentially be in Unicode range.
 
 This can be used to determine whether the Perl interpreter executing a
 script is in the right range of versions.  (Mnemonic: use ^V for Version
-control.)  Example:
+Control.)  Example:
 
-    warn "No "our" declarations!\n" if $^V and $^V lt v5.6;
+    warn "No "our" declarations!\n" if $^V and $^V lt v5.6.0;
 
-See also the documentation of C<use VERSION> and C<require VERSION>
+See the documentation of C<use VERSION> and C<require VERSION>
 for a convenient way to fail if the running Perl interpreter is too old.
 
 See also C<$]> for an older representation of the Perl version.

==== //depot/perl/t/comp/require.t#10 (xtext) ====
Index: perl/t/comp/require.t
--- perl/t/comp/require.t.~1~	Mon Feb 21 13:10:31 2000
+++ perl/t/comp/require.t	Mon Feb 21 13:10:31 2000
@@ -7,7 +7,7 @@
 
 # don't make this lexical
 $i = 1;
-print "1..20\n";
+print "1..18\n";
 
 sub do_require {
     %INC = ();
@@ -59,25 +59,25 @@
 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
 print "ok ",$i++,"\n";
 
-my $ver = v5.5.630;
+my $ver = 5.005_63;
 eval { require $ver; };
 print "# $@\nnot " if $@;
 print "ok ",$i++,"\n";
 
-$ver = v10.0.2;
+# check inaccurate fp
+#$ver = 10.2;
+#eval { require $ver; };
+#print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/;
+#print "ok ",$i++,"\n";
+
+$ver = 10.000_02;
 eval { require $ver; };
-print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
+print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.20 required/;
 print "ok ",$i++,"\n";
 
 print "not " unless v5.5.1 gt v5.5;
 print "ok ",$i++,"\n";
 
-print "not " unless 5.005_01 > v5.5;
-print "ok ",$i++,"\n";
-
-print "not " unless 5.005_64 - v5.5.640 < 0.0000001;
-print "ok ",$i++,"\n";
-
 {
     use utf8;
     print "not " unless v5.5.640 eq "\x{5}\x{5}\x{280}";

==== //depot/perl/t/op/ver.t#4 (xtext) ====
Index: perl/t/op/ver.t
--- perl/t/op/ver.t.~1~	Mon Feb 21 13:10:31 2000
+++ perl/t/op/ver.t	Mon Feb 21 13:10:31 2000
@@ -5,7 +5,7 @@
     unshift @INC, "../lib";
 }
 
-print "1..15\n";
+print "1..14\n";
 
 my $test = 1;
 
@@ -16,9 +16,6 @@
 print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
 print "ok $test\n";  ++$test;
 
-print "not " unless v1.20.300.4000 > 1.0203039 and v1.20.300.4000 < 1.0203041;
-print "ok $test\n";  ++$test;
-
 print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
 print "ok $test\n";  ++$test;
 

==== //depot/perl/toke.c#202 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~	Mon Feb 21 13:10:31 2000
+++ perl/toke.c	Mon Feb 21 13:10:31 2000
@@ -821,18 +821,27 @@
 S_force_version(pTHX_ char *s)
 {
     OP *version = Nullop;
+    bool is_vstr = FALSE;
+    char *d;
 
     s = skipspace(s);
 
-    if (isDIGIT(*s) || (*s == 'v' && isDIGIT(s[1]))) {
-        char *d = s;
-	if (*d == 'v')
-	    d++;
+    d = s;
+    if (*d == 'v') {
+	is_vstr = TRUE;
+	d++;
+    }
+    if (isDIGIT(*d)) {
         for (; isDIGIT(*d) || *d == '_' || *d == '.'; d++);
         if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) {
             s = scan_num(s);
             /* real VERSION number -- GBARR */
             version = yylval.opval;
+	    if (is_vstr) {
+		SV *ver = cSVOPx(version)->op_sv;
+		SvUPGRADE(ver, SVt_PVIV);
+		SvIOKp_on(ver);		/* hint that it is a version */
+	    }
         }
     }
 
@@ -6899,12 +6908,10 @@
 		UV rev;
 		U8 tmpbuf[UTF8_MAXLEN];
 		U8 *tmpend;
-		NV nshift = 1.0;
 		bool utf8 = FALSE;
 		s++;				/* get past 'v' */
 
 		sv = NEWSV(92,5);
-		SvUPGRADE(sv, SVt_PVNV);
 		sv_setpvn(sv, "", 0);
 
 		do {
@@ -6924,9 +6931,6 @@
 			tmpend = &tmpbuf[1];
 		    }
 		    sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
-		    if (rev > 0)
-			SvNVX(sv) += (NV)rev/nshift;
-		    nshift *= 1000;
 		} while (*pos == '.' && isDIGIT(pos[1]));
 
 		if (*s == '0' && isDIGIT(s[1]))
@@ -6936,11 +6940,8 @@
 		tmpend = uv_to_utf8(tmpbuf, rev);
 		utf8 = utf8 || rev > 127;
 		sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
-		if (rev > 0)
-		    SvNVX(sv) += (NV)rev/nshift;
 
 		SvPOK_on(sv);
-		SvNOK_on(sv);
 		SvREADONLY_on(sv);
 		if (utf8) {
 		    SvUTF8_on(sv);
End of Patch.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About