From: Gurusamy Sarathy Date: Sun, 30 Jan 2000 21:27:12 +0000 (+0000) Subject: introduce $^V (eq chr($revision) . chr($version) . chr($subversion)); X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=16070b82c8557c1a47b3ee4bee2b551efb7b3eb7;p=p5sagit%2Fp5-mst-13.2.git introduce $^V (eq chr($revision) . chr($version) . chr($subversion)); document version tuples p4raw-id: //depot/perl@4927 --- diff --git a/gv.c b/gv.c index 854a822..5a91c08 100644 --- a/gv.c +++ b/gv.c @@ -829,20 +829,20 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) case '\\': case '/': case '|': - case '\001': - case '\003': - case '\004': - case '\005': - case '\006': - case '\010': - case '\011': /* NOT \t in EBCDIC */ - case '\017': - case '\020': - case '\024': + case '\001': /* $^A */ + case '\003': /* $^C */ + case '\004': /* $^D */ + case '\005': /* $^E */ + case '\006': /* $^F */ + case '\010': /* $^H */ + case '\011': /* $^I, NOT \t in EBCDIC */ + case '\017': /* $^O */ + case '\020': /* $^P */ + case '\024': /* $^T */ if (len > 1) break; goto magicalize; - case '\023': + case '\023': /* $^S */ if (len > 1) break; goto ro_magicalize; @@ -874,7 +874,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) sv_magic(GvSV(gv), (SV*)gv, 0, name, len); break; - case '\014': + case '\014': /* $^L */ if (len > 1) break; sv_setpv(GvSV(gv),"\f"); @@ -895,6 +895,13 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) SvREADONLY_on(sv); } break; + case '\026': /* $^V */ + if (len == 1) { + SV *sv = GvSV(gv); + GvSV(gv) = SvREFCNT_inc(PL_patchlevel); + SvREFCNT_dec(sv); + } + break; } return gv; } diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 6fc7d8f..efa1a2f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -270,12 +270,50 @@ For the full list of public API functions, see L. =head1 Installation and Configuration Improvements +=head2 -Dusethreads means something different + +WARNING: Support for threads continues to be an experimental feature. +Interfaces and implementation are subject to sudden and drastic changes. + +The -Dusethreads flag now enables the experimental interpreter-based thread +support by default. To get the flavor of experimental threads that was in +5.005 instead, you need to ask for -Duse5005threads. + +As of v5.5.640, interpreter-threads support is still lacking a way to +create new threads from Perl (i.e., C will not work with +interpreter threads). C 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 +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 by running Configure with C<-Dflag>. usemultiplicity + use5005threads uselongdouble usemorebits @@ -343,7 +381,7 @@ Perl can optionally use UTF-8 as its internal representation for character strings. The C pragma enables this support in the current lexical scope. See L for more information. -=head2 Interpreter threads +=head2 Interpreter cloning, threads, and concurrency WARNING: This is an experimental feature in a pre-alpha state. Use at your own risk. @@ -367,24 +405,24 @@ interpreters, little or no locking will be needed (unless parts of the symbol table are explicitly shared). This is obviously intended to be an easy-to-use replacement for the existing threads support. -Support for cloning interpreters must currently be manually enabled -by defining the cpp macro USE_ITHREADS on non-Windows platforms. -(See win32/Makefile for how to enable it on Windows.) The resulting -perl executable will be functionally identical to one that was built -without USE_ITHREADS, but the perl_clone() API call will only be -available in the former. +Support for cloning interpreters and interpreter concurrency can be +enabled using the -Dusethreads Configure option (see win32/Makefile for +how to enable it on Windows.) The resulting perl executable will be +functionally identical to one that was built with -Dmultiplicity, but +the perl_clone() API call will only be available in the former. -USE_ITHREADS enables Perl source code changes that provide a clear -separation between the op tree and the data it operates with. The -former is considered immutable, and can therefore be shared between -an interpreter and all of its clones, while the latter is considered -local to each interpreter, and is therefore copied for each clone. +-Dusethreads enables, the cpp macros USE_ITHREADS by default, which enables +Perl source code changes that provide a clear separation between the op tree +and the data it operates with. The former is considered immutable, and can +therefore be shared between an interpreter and all of its clones, while the +latter is considered local to each interpreter, and is therefore copied for +each clone. Note that building Perl with the -Dusemultiplicity Configure option is adequate if you wish to run multiple B interpreters -concurrently in different threads. USE_ITHREADS only needs to be -enabled if you wish to obtain access to perl_clone() and cloned -interpreters. +concurrently in different threads. -Dusethreads only provides the +additional functionality of the perl_clone() API call and other +support for running B interpreters concurrently. [XXX TODO - the Compiler backends may be broken when USE_ITHREADS is enabled.] @@ -407,9 +445,36 @@ Tuomas Lukka )] An "our" declaration introduces a value that can be best understood as a lexically scoped symbolic alias to a global variable in the -current package. This is mostly useful as an alternative to the -C pragma, but also provides the opportunity to introduce -typing and other attributes for such variables. See L. +package that was current where the variable was declared. This is +mostly useful as an alternative to the C pragma, but also provides +the opportunity to introduce typing and other attributes for such +variables. See L. + +=head2 Support for version tuples + +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, C, C, C etc. + +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. + +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. + + if ($^V and $^V gt v5.5.640) { + # new style version numbers are supported + } + +C and C also support such literals: + + require v5.6.0; # croak if $^V lt v5.6.0 + use v5.6.0; # same, but croaks at compile-time =head2 Weak references @@ -689,14 +754,24 @@ acquire special meaning in any future version of Perl. Formerly, if you wanted to mark a subroutine as being a method call or as requiring an automatic lock() when it is entered, you had to declare that with a C pragma in the body of the subroutine. -That can now be accomplished with a declaration syntax, like this: +That can now be accomplished with declaration syntax, like this: sub mymethod : locked method ; ... - sub mymethod : locked :method { + sub mymethod : locked method { + ... + } + + sub othermethod :locked :method ; + ... + sub othermethod :locked :method { ... } + +(Note how only the first C<:> is mandatory, and whitespace surrounding +the C<:> is optional.) + F and F have been updated to keep the attributes with the stubs they provide. See L. @@ -740,6 +815,12 @@ BEGIN blocks are executed under such conditions, this variable enables perl code to determine whether actions that make sense only during normal running are warranted. See L. +=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 for an example. + =head2 Optional Y2K warnings If Perl is built with the cpp macro C defined, @@ -1102,6 +1183,14 @@ detected at the end of the line containing the __END__ or __DATA__ token; if not, the DATA filehandle will be left open in binary mode. Earlier versions always opened the DATA filehandle in text mode. +The glob() operator is implemented via the L extension, +which supports glob syntax of the C. This increases the flexibility +of the glob() operator, but there may be compatibility issues for +programs that relied on the older globbing syntax. If you want to +preserve compatibility with the older syntax, you might want to put +a C in your program. For details and compatibility +information, see L. + [TODO - GSAR] =head1 New tests diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 060bb64..a72645a 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3526,13 +3526,16 @@ for this. Other restrictions include whether it works on directories, open files, or pre-existing files. Check L and either the rename(2) manpage or equivalent system documentation for details. +=item require VERSION + =item require EXPR =item require Demands some semantics specified by EXPR, or by C<$_> if EXPR is not -supplied. If EXPR is numeric, demands that the current version of Perl -(C<$]> or $PERL_VERSION) be equal or greater than EXPR. +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. 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 @@ -5143,13 +5146,17 @@ package. It is exactly equivalent to except that Module I be a bareword. -If the first argument to C is a number, it is treated as a version -number 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. This is often useful if you need to check the current -Perl version before Cing library modules that have changed in -incompatible ways from older versions of Perl. (We try not to do -this more than we have to.) +If the first argument to C 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. + + use 5.005_03; # version number + use v5.6.0; # version tuple + +This is often useful if you need to check the current Perl version before +Cing library modules that have changed in incompatible ways from +older versions of Perl. (We try not to do this more than we have to.) The C forces the C and C to happen at compile time. The C makes sure the module is loaded into memory if it hasn't been diff --git a/pod/perlop.pod b/pod/perlop.pod index 5a901c0..68113b7 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -1802,6 +1802,17 @@ operation you intend by using C<""> or C<0+>, as in the examples below. See L for information on how to manipulate individual bits in a bit vector. +=head2 Version tuples + +A version number of the form C is parsed as a dual-valued literal. +It has the string value of C<"\x{1}\x{2}\x{3}\x{4}"> (i.e., a utf8 string) +and a numeric value of C<1 + 2/1000 + 3/1000000 + 4/1000000000>. This is +useful for representing and comparing version numbers. + +Version tuples are accepted by both C and C. The C<$^V> variable +contains the running Perl interpreter's version in this format. +See L. + =head2 Integer Arithmetic By default, Perl assumes that it must do most of its arithmetic in @@ -1889,3 +1900,5 @@ limited-precision representations. The non-standard modules SSLeay::BN and Math::Pari provide equivalent functionality (and much more) with a substantial performance savings. + +=cut diff --git a/pod/perlvar.pod b/pod/perlvar.pod index a43ab60..3094251 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -686,6 +686,8 @@ of perl in the right bracket?) Example: See also the documentation of C and C 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. + =item $COMPILING =item $^C @@ -854,6 +856,26 @@ The time at which the program began running, in seconds since the epoch (beginning of 1970). The values returned by the B<-M>, B<-A>, and B<-C> filetests are based on this value. +=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 utf8 characters: +C. + +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: + + warn "No "our" declarations!\n" if $^V and $^V lt v5.6; + +See also the documentation of C and C +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. + =item $WARNING =item $^W