s/STOP/CHECK/ blocks
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
index 8b56750..495e2ff 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perldelta - what's new for perl v5.6 (as of v5.005_62)
+perldelta - what's new for perl v5.6 (as of v5.005_64)
 
 =head1 DESCRIPTION
 
@@ -15,8 +15,8 @@ This document describes differences between the 5.005 release and this one.
 
 =head2 Perl Source Incompatibilities
 
-Beware that any new warnings that have been added or enhanced old
-warnings are B<not> considered incompatible changes.
+Beware that any new warnings that have been added or old ones
+that have been enhanced are B<not> considered incompatible changes.
 
 Since all new warnings must be explicitly requested via the C<-w>
 switch or the C<warnings> pragma, it is ultimately the programmer's
@@ -24,6 +24,14 @@ responsibility to ensure that warnings are enabled judiciously.
 
 =over 4
 
+=item CHECK is a new keyword
+
+In addition to C<BEGIN>, C<INIT>, C<END>, C<DESTROY> and C<AUTOLOAD>,
+subroutines named C<CHECK> are now special.  These are queued up during
+compilation and behave similar to END blocks, except they are called at
+the end of compilation rather than at the end of execution.  They cannot
+be called directly.
+
 =item Treatment of list slices of undef has changed
 
 When taking a slice of a literal list (as opposed to a slice of
@@ -89,9 +97,9 @@ but still allowed it.
 
 In Perl 5.6 and later, C<"$$1"> always means C<"${$1}">.
 
-=item values(%h) and C<\(%h)> operate on aliases to values, not copies
+=item delete(), values() and C<\(%h)> operate on aliases to values, not copies
 
-each(), values() and hashes in a list context return the actual
+delete(), each(), values() and hashes in a list context return the actual
 values in the hash, instead of copies (as they used to in earlier
 versions).  Typical idioms for using these constructs copy the
 returned values, but this can make a significant difference when
@@ -119,6 +127,36 @@ The undocumented special variable C<%@> that used to accumulate
 has been removed, because it could potentially result in memory
 leaks.
 
+=item Parenthesized not() behaves like a list operator
+
+The C<not> operator now falls under the "if it looks like a function,
+it behaves like a function" rule.
+
+As a result, the parenthesized form can be used with C<grep> and C<map>.
+The following construct used to be a syntax error before, but it works
+as expected now:
+
+    grep not($_), @things;
+
+On the other hand, using C<not> with a literal list slice may not
+work.  The following previously allowed construct:
+
+    print not (1,2,3)[0];
+
+needs to be written with additional parentheses now:
+
+    print not((1,2,3)[0]);
+
+The behavior remains unaffected when C<not> is not followed by parentheses.
+
+=item Semantics of bareword prototype C<(*)> have changed
+
+Arguments prototyped as C<*> will now be visible within the subroutine
+as either a simple scalar or as a reference to a typeglob.  Perl 5.005
+always coerced simple scalar arguments to a typeglob, which wasn't useful
+in situations where the subroutine must distinguish between a simple
+scalar and a typeglob.  See L<perlsub/Prototypes>.
+
 =back
 
 =head2 C Source Incompatibilities
@@ -138,6 +176,10 @@ specified via MakeMaker:
 
 =item C<PERL_IMPLICIT_CONTEXT>
 
+PERL_IMPLICIT_CONTEXT is automatically enabled whenever Perl is built
+with one of -Dusethreads, -Dusemultiplicity, or both.  It is not
+intended to be enabled by users at this time.
+
 This new build option provides a set of macros for all API functions
 such that an implicit interpreter/thread context argument is passed to
 every API function.  As a result of this, something like C<sv_setsv(foo,bar)>
@@ -154,9 +196,6 @@ Note that the above issue is not relevant to the default build of
 Perl, whose interfaces continue to match those of prior versions
 (but subject to the other options described here).
 
-PERL_IMPLICIT_CONTEXT is automatically enabled whenever Perl is built
-with one of -Dusethreads, -Dusemultiplicity, or both.
-
 See L<perlguts/"The Perl API"> for detailed information on the
 ramifications of building Perl using this option.
 
@@ -292,6 +331,52 @@ Perl can optionally use UTF-8 as its internal representation for character
 strings.  The C<utf8> pragma enables this support in the current lexical
 scope.  See L<utf8> for more information.
 
+=head2 Interpreter threads
+
+WARNING: This is an experimental feature in a pre-alpha state.  Use
+at your own risk.
+
+Perl 5.005_63 introduces the beginnings of support for running multiple
+interpreters concurrently in different threads.  In conjunction with
+the perl_clone() API call, which can be used to selectively duplicate
+the state of any given interpreter, it is possible to compile a
+piece of code once in an interpreter, clone that interpreter
+one or more times, and run all the resulting interpreters in distinct
+threads.
+
+On Windows, this feature is used to emulate fork() at the interpreter
+level.  See L<perlfork>.
+
+This feature is still in evolution.  It is eventually meant to be used
+to selectively clone a subroutine and data reachable from that
+subroutine in a separate interpreter and run the cloned subroutine
+in a separate thread.  Since there is no shared data between the
+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.
+
+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.
+
+Note that building Perl with the -Dusemultiplicity Configure option
+is adequate if you wish to run multiple B<independent> interpreters
+concurrently in different threads.  USE_ITHREADS only needs to be
+enabled if you wish to obtain access to perl_clone() and cloned
+interpreters.
+
+[XXX TODO - the Compiler backends may be broken when USE_ITHREADS is
+enabled.]
+
 =head2 Lexically scoped warning categories
 
 You can now control the granularity of warnings emitted by perl at a finer
@@ -327,9 +412,9 @@ change#3385, also need perlguts documentation
 WARNING: This is currently an experimental feature.  Interfaces and
 implementation are likely to change.
 
-Perl can be compiled with -DPERL_INTERNAL_GLOB to use the File::Glob
-implementation of the glob() operator.  This avoids using an external
-csh process and the problems associated with it.
+Perl now uses the File::Glob implementation of the glob() operator
+automatically.  This avoids using an external csh process and the
+problems associated with it.
 
 =head2 Binary numbers supported
 
@@ -348,17 +433,45 @@ This is rather similar to how the arrow may be omitted from
 C<$foo[10]->{'foo'}>.  Note however, that the arrow is still
 required for C<foo(10)->('bar')>.
 
+=head2 exists() is supported on subroutine names
+
+The exists() builtin now works on subroutine names.  A subroutine
+is considered to exist if it has been declared (even if implicitly).
+See L<perlfunc/exists> for examples.
+
+=head2 exists() and delete() are supported on array elements
+
+The exists() and delete() builtins now work on simple arrays as well.
+The behavior is similar to that on hash elements.
+
+exists() can be used to check whether an array element has been
+initialized without autovivifying it.  If the array is tied, the
+EXISTS() method in the corresponding tied package will be invoked.
+
+delete() may be used to remove an element from the array and return
+it.  The array element at that position returns to its unintialized
+state, so that testing for the same element with exists() will return
+false.  If the element happens to be the one at the end, the size of
+the array also shrinks by one.  If the array is tied, the DELETE() method
+in the corresponding tied package will be invoked.
+
+See L<perlfunc/exists> and L<perlfunc/delete> for examples.
+
 =head2 syswrite() ease-of-use
 
 The length argument of C<syswrite()> has become optional.
 
-=head2 Filehandles can be autovivified
+=head2 File and directory handles can be autovivified
 
-The construct C<open(my $fh, ...)> can be used to create filehandles
-more easily.  The filehandle will be automatically closed at the end
-of the scope of $fh, provided there are no other references to it.  This
-largely eliminates the need for typeglobs when opening filehandles
-that must be passed around, as in the following example:
+Similar to how constructs such as C<$x->[0]> autovivify a reference,
+handle constructors (open(), opendir(), pipe(), socketpair(), sysopen(),
+socket(), and accept()) now autovivify a file or directory handle
+if the handle passed to them is an uninitialized scalar variable.  This
+allows the constructs such as C<open(my $fh, ...)> and C<open(local $fh,...)>
+to be used to create filehandles that will conveniently be closed
+automatically when the scope ends, provided there are no other references
+to them.  This largely eliminates the need for typeglobs when opening
+filehandles that must be passed around, as in the following example:
 
     sub myopen {
         open my $fh, "@_"
@@ -431,7 +544,9 @@ start losing precision (their lower digits).
 If you have filesystems that support "large files" (files larger than
 2 gigabytes), you may now also be able to create and access them from
 Perl.  You have to use Configure -Duselargefiles.  Turning on the
-large file support turns on also the 64-bit support, for obvious reasons.
+large file support turns on also the 64-bit support on many platforms.
+Beware that unless your filesystem also supports "sparse files" seeking
+to umpteen petabytes may be unadvisable.
 
 Note that in addition to requiring a proper file system to do large
 files you may also need to adjust your per-process (or your
@@ -454,15 +569,25 @@ process resource usage limits, including the maximum filesize limit.
 =head2 Long doubles
 
 In some systems you may be able to use long doubles to enhance the
-range of precision of your double precision floating point numbers
+range and precision of your double precision floating point numbers
 (that is, Perl's numbers).  Use Configure -Duselongdouble to enable
 this support (if it is available).
 
 =head2 "more bits"
 
-You can Configure -Dusemorebits to turn on both the 64-bit support
+You can "Configure -Dusemorebits" to turn on both the 64-bit support
 and the long double support.
 
+=head2 Enhanced support for sort() subroutines
+
+Perl subroutines with a prototype of C<($$)> and XSUBs in general can
+now be used as sort subroutines.  In either case, the two elements to
+be compared are passed as normal parameters in @_.  See L<perlfunc/sort>.
+
+For unprototyped sort subroutines, the historical behavior of passing 
+the elements to be compared as the global variables $a and $b remains
+unchanged.
+
 =head2 Better syntax checks on parenthesized unary operators
 
 Expressions such as:
@@ -616,9 +741,10 @@ See L<INSTALL> and L<README.Y2K>.
 
 =head2 E<lt>HANDLEE<gt> on empty files
 
-With C<$/> set to C<undef>, slurping an empty file returns a string of
+With C<$/> set to C<undef>, "slurping" an empty file returns a string of
 zero length (instead of C<undef>, as it used to) the first time the
-HANDLE is read.  Further reads yield C<undef>.
+HANDLE is read after C<$/> is set to C<undef>.  Further reads yield
+C<undef>.
 
 This means that the following will append "foo" to an empty file (it used
 to do nothing):
@@ -685,6 +811,12 @@ on C<NEW> will return the same data as the corresponding operation
 on C<OLD>.  Formerly, it would have returned the data from the start
 of the following disk block instead.
 
+=head2 eof() has the same old magic as <>
+
+C<eof()> would return true if no attempt to read from C<E<lt>E<gt>> had
+yet been made.  C<eof()> has been changed to have a little magic of its
+own, it now opens the C<E<lt>E<gt>> files.
+
 =head2 system(), backticks and pipe open now reflect exec() failure
 
 On Unix and similar platforms, system(), qx() and open(FOO, "cmd |")
@@ -716,6 +848,10 @@ been corrected.
 When applied to a pseudo-hash element, exists() now reports whether
 the specified value exists, not merely if the key is valid.
 
+delete() now works on pseudo-hashes.  When given a pseudo-hash element
+or slice it deletes the values corresponding to the keys (but not the keys
+themselves).  See L<perlref/"Pseudo-hashes: Using an array as a hash">.
+
 =head2 C<goto &sub> and AUTOLOAD
 
 The C<goto &sub> construct works correctly when C<&sub> happens
@@ -789,9 +925,7 @@ run in compile-only mode.  Since this is typically not the expected
 behavior, END blocks are not executed anymore when the C<-c> switch
 is used.
 
-Note that something resembling the previous behavior can still be
-obtained by putting C<BEGIN { $^C = 0; exit; }> at the very end of
-the top level source file.
+See L<CHECK blocks> for how to run things when the compile phase ends.
 
 =head2 Potential to leak DATA filehandles
 
@@ -893,7 +1027,25 @@ EPOC is is now supported (on Psion 5).
 
 =head2 DOS
 
-[TODO - Laszlo Molnar <laszlo.molnar@eth.ericsson.se>]
+=over 4
+
+=item *
+
+Perl now works with djgpp 2.02 (and 2.03 alpha).
+
+=item *
+
+Environment variable names are not converted to uppercase any more.
+
+=item *
+
+Wrong exit code from backticks now fixed.
+
+=item *
+
+This port is still using its own builtin globbing.
+
+=back
 
 =head2 OS/2
 
@@ -931,6 +1083,13 @@ The C<Shell> module is supported.
 Rudimentary support for building under command.com in Windows 95
 has been added.
 
+Scripts are read in binary mode by default to allow ByteLoader (and
+the filter mechanism in general) to work properly.  For compatibility,
+the DATA filehandle will be set to text mode if a carriage return is
+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.
+
 [TODO - GSAR]
 
 =head1 New tests
@@ -973,6 +1132,10 @@ File test operators.
 
 Verify operations that access pad objects (lexicals and temporaries).
 
+=item  op/exists_sub
+
+Verify C<exists &sub> operations.
+
 =back
 
 =head1 Modules and Pragmata
@@ -1002,7 +1165,17 @@ Perl bytecode.  See L<ByteLoader>.
 
 =item constant
 
-References can now be used.  See L<constant>.
+References can now be used.
+
+The new version also allows a leading underscore in constant names, but
+disallows a double leading underscore (as in "__LINE__").  Some other names
+are disallowed or warned against, including BEGIN, END, etc.  Some names
+which were forced into main:: used to fail silently in some cases; now they're
+fatal (outside of main::) and an optional warning (inside of main::).
+The ability to detect whether a constant had been set with a given name has
+been added.
+
+See L<constant>.
 
 =item charnames
 
@@ -1023,11 +1196,13 @@ to Perl's debugging API.
 
 =item DB_File
 
-[TODO - Paul Marquess <paul.marquess@bt.com>]
+DB_File can now be built with Berkeley DB versions 1, 2 or 3.
+See C<ext/DB_File/Changes>.
 
 =item Devel::DProf
 
-Devel::DProf, a Perl source code profiler has been added.  See L<DProf>.
+Devel::DProf, a Perl source code profiler has been added.  See
+L<Devel::DProf> and L<dprofpp>.
 
 =item Dumpvalue
 
@@ -1086,10 +1261,12 @@ change#4135, also needs docs in module pod
 =item Fcntl
 
 More Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE for
-large (more than 4G) file access (64-bit support is not yet
-working, though, so no need to get overly excited), Free/Net/OpenBSD
-locking behaviour flags F_FLOCK, F_POSIX, Linux F_SHLCK, and
-O_ACCMODE: the mask of O_RDONLY, O_WRONLY, and O_RDWR.
+large file (more than 4GB) access Note that the O_LARGEFILE is
+automatically/transparently added to sysopen() flags if large file
+support has been configured), Free/Net/OpenBSD locking behaviour flags
+F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the combined mask of
+O_RDONLY, O_WRONLY, and O_RDWR.  Also SEEK_SET, SEEK_CUR, and SEEK_END
+added for one-stop shopping of the seek/sysseek constants.
 
 =item File::Compare
 
@@ -1104,11 +1281,19 @@ autoloaded or is a symbolic reference.
 A bug that caused File::Find to lose track of the working directory
 when pruning top-level directories has been fixed.
 
+File::Find now also supports several other options to control its
+behavior.  It can follow symbolic links if the C<follow> option is
+specified.  Enabling the C<no_chdir> option will make File::Find skip
+changing the current directory when walking directories.  The C<untaint>
+flag can be useful when running with taint checks enabled.
+
+See L<File::Find>.
+
 =item File::Glob
 
-This extension implements BSD-style file globbing.  It will also be
-used for the internal implementation of the glob() operator if
-Perl was compiled with -DPERL_INTERNAL_GLOB.  See L<File::Glob>.
+This extension implements BSD-style file globbing.  By default,
+it will also be used for the internal implementation of the glob()
+operator.  See L<File::Glob>.
 
 =item File::Spec
 
@@ -1342,6 +1527,10 @@ change#4232
 
 An introduction to using the Perl Compiler suite.
 
+=item perlfilter.pod
+
+An introduction to writing Perl source filters.
+
 =item perlhack.pod
 
 Some guidelines for hacking the Perl source code.
@@ -1364,11 +1553,24 @@ A tutorial on managing class data for object modules.
 
 =over 4
 
+=item "%s" variable %s masks earlier declaration in same %s
+
+(W) A "my" or "our" variable has been redeclared in the current scope or statement,
+effectively eliminating all access to the previous instance.  This is almost
+always a typographical error.  Note that the earlier variable will still exist
+until the end of the scope or until all closure referents to it are
+destroyed.
+
 =item "my sub" not yet implemented
 
 (F) Lexically scoped subroutines are not yet implemented.  Don't try that
 yet.
 
+=item "our" variable %s redeclared
+
+(W) You seem to have already declared the same global once before in the
+current lexical scope.
+
 =item '!' allowed only after types %s
 
 (F) The '!' is allowed in pack() and unpack() only after certain types.
@@ -1399,16 +1601,6 @@ See L<perlfunc/pack>.
 but this did not follow some numeric unpack specification.
 See L<perlfunc/pack>.
 
-=item Repeat count in pack overflows
-
-(F) You can't specify a repeat count so large that it overflows
-your signed integers.  See L<perlfunc/pack>.
-
-=item Repeat count in unpack overflows
-
-(F) You can't specify a repeat count so large that it overflows
-your signed integers.  See L<perlfunc/unpack>.
-
 =item /%s/: Unrecognized escape \\%c passed through
 
 (W) You used a backslash-character combination which is not recognized
@@ -1437,6 +1629,30 @@ definition ahead of the call to get proper prototype checking.  Alternatively,
 if you are certain that you're calling the function correctly, you may put
 an ampersand before the name to avoid the warning.  See L<perlsub>.
 
+=item %s argument is not a HASH or ARRAY element
+
+(F) The argument to exists() must be a hash or array element, such as:
+
+    $foo{$bar}
+    $ref->[12]->["susie"]
+
+=item %s argument is not a HASH or ARRAY element or slice
+
+(F) The argument to delete() must be either a hash or array element, such as:
+
+    $foo{$bar}
+    $ref->[12]->["susie"]
+
+or a hash or array slice, such as:
+
+    @foo[$bar, $baz, $xyzzy]
+    @{$ref->[12]}{"susie", "queue"}
+
+=item %s argument is not a subroutine name
+
+(F) The argument to exists() for C<exists &sub> must be a subroutine
+name, and not a subroutine call.  C<exists &sub()> will generate this error.
+
 =item %s package attribute may clash with future reserved word: %s
 
 (W) A lowercase attribute name was used that had a package-specific handler.
@@ -1499,6 +1715,26 @@ so it was truncated to the string shown.
 
 (P) For some reason you can't check the filesystem of the script for nosuid.
 
+=item Can't declare class for non-scalar %s in "%s"
+
+(S) Currently, only scalar variables can declared with a specific class
+qualifier in a "my" or "our" declaration.  The semantics may be extended
+for other types of variables in future.
+
+=item Can't declare %s in "%s"
+
+(F) Only scalar, array, and hash variables may be declared as "my" or
+"our" variables.  They must have ordinary identifiers as names.
+
+=item Can't ignore signal CHLD, forcing to default
+
+(W) Perl has detected that it is being run with the SIGCHLD signal
+(sometimes known as SIGCLD) disabled.  Since disabling this signal
+will interfere with proper determination of exit status of child
+processes, Perl has reset the signal to its default value.
+This situation typically indicates that the parent program under
+which Perl may be running (e.g. cron) is being very careless.
+
 =item Can't modify non-lvalue subroutine call
 
 (F) Subroutines meant to be used in lvalue context should be declared as
@@ -1575,6 +1811,11 @@ just use C<if (%hash) { # not empty }> for example.
 
 See Server error.
 
+=item Did you mean "local" instead of "our"?
+
+(W) Remember that "our" does not localize the declared global variable.
+You have declared it again in the same lexical scope, which seems superfluous.
+
 =item Document contains no data
 
 See Server error.
@@ -1599,6 +1840,19 @@ intended it to be a read/write filehandle, you needed to open it with
 you intended only to read from the file, use "E<lt>".  See
 L<perlfunc/open>.
 
+=item flock() on closed filehandle %s
+
+(W) The filehandle you're attempting to flock() got itself closed some
+time before now.  Check your logic flow.  flock() operates on filehandles.
+Are you attempting to call flock() on a dirhandle by the same name?
+
+=item Global symbol "%s" requires explicit package name
+
+(F) You've said "use strict vars", which indicates that all variables
+must either be lexically scoped (using "my"), declared beforehand using
+"our", or explicitly qualified to say which package the global variable
+is in (using "::").
+
 =item Hexadecimal number > 0xffffffff non-portable
 
 (W) The hexadecimal number you specified is larger than 2**32-1
@@ -1702,6 +1956,22 @@ construction, but the command was missing or blank.
 (F) The reserved syntax for lexically scoped subroutines requires that they
 have a name with which they can be found.
 
+=item No %s specified for -%c
+
+(F) The indicated command line switch needs a mandatory argument, but
+you haven't specified one.
+
+=item No package name allowed for variable %s in "our"
+
+(F) Fully qualified variable names are not allowed in "our" declarations,
+because that doesn't make much sense under existing semantics.  Such
+syntax is reserved for future extensions.
+
+=item No space allowed after -%c
+
+(F) The argument to the indicated command line switch must follow immediately
+after the switch, without intervening spaces.
+
 =item no UTC offset information; assuming local time is UTC
 
 (S) A warning peculiar to VMS.  Perl was unable to find the local
@@ -1732,6 +2002,18 @@ reference.
 (P) Failed an internal consistency check while trying to reset all weak
 references to an object.
 
+=item Parentheses missing around "%s" list
+
+(W) You said something like
+
+    my $foo, $bar = @_;
+
+when you meant
+
+    my ($foo, $bar) = @_;
+
+Remember that "my", "our" and "local" bind closer than comma.
+
 =item Possible Y2K bug: %s
 
 (W) You are concatenating the number 19 with another number, which
@@ -1741,6 +2023,16 @@ could be a potential Year 2000 problem.
 
 See Server error.
 
+=item Repeat count in pack overflows
+
+(F) You can't specify a repeat count so large that it overflows
+your signed integers.  See L<perlfunc/pack>.
+
+=item Repeat count in unpack overflows
+
+(F) You can't specify a repeat count so large that it overflows
+your signed integers.  See L<perlfunc/unpack>.
+
 =item realloc() of freed memory ignored
 
 (S) An internal routine called realloc() on something that had already