X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperldelta.pod;h=c5104b0e27938081c7b1c7206afba936bd4c4412;hb=ab4f32c297ca404165732c897d45e499965c42dc;hp=48c04b3294beed40dbf004e827d08ba320ac775d;hpb=878e08dfd37ef18d0471607a99b747ae9fd31e93;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 48c04b3..c5104b0 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -1,1433 +1,659 @@ =head1 NAME -perldelta - what's new for perl5.004 +perldelta - what's new for perl5.005 =head1 DESCRIPTION -This document describes differences between the 5.003 release (as -documented in I, second edition--the Camel Book) and -this one. +This document describes differences between the 5.004 release and this one. -=head1 Supported Environments +[XXX this needs more verbose summaries of the sub topics, instead of just +the "See L." Scheduled for a second iteration. GSAR] -Perl5.004 builds out of the box on Unix, Plan9, LynxOS, VMS, OS/2, -QNX, AmigaOS, and Windows NT; once built on Windows NT, Perl runs -on Windows 95 as well. +=head1 About the new versioning system -=head1 Core Changes - -Most importantly, many bugs were fixed. See the F -file in the distribution for details. - -=head2 Compilation option: Binary compatibility with 5.003 - -There is a new Configure question that asks if you want to maintain -binary compatibility with Perl 5.003. If you choose binary -compatibility, you do not have to recompile your extensions, but you -might have symbol conflicts if you embed Perl in another application, -just as in the 5.003 release. By default, binary compatibility -is preserved at the expense of symbol table pollution. - -=head2 $PERL5OPT environment variable - -You may now put Perl options in the $PERL5OPT environment variable. -Unless Perl is running with taint checks, it will interpret this -variable as if its contents had appeared on a "#!perl" line at the -beginning of your script, except that hyphens are optional. PERL5OPT -may only be used to set the following switches: B<-[DIMUdmw]>. - -=head2 Limitations on B<-M>, and C<-m>, and B<-T> options - -The C<-M> and C<-m> options are no longer allowed on the C<#!> line of -a script. If a script needs a module, it should invoke it with the -C pragma. - -The B<-T> option is also forbidden on the C<#!> line of a script, -unless it was present on the Perl command line. Due to the way C<#!> -works, this usually means that B<-T> must be in the first argument. -Thus: - - #!/usr/bin/perl -T -w - -will probably work for an executable script invoked as C, -while: - - #!/usr/bin/perl -w -T - -will probably fail under the same conditions. (Non-Unix systems will -probably not follow this rule.) But C is guaranteed -to fail, since then there is no chance of B<-T> being found on the -command line before it is found on the C<#!> line. +=head1 Incompatible Changes -=head2 More precise warnings +=head2 WARNING: This version is not binary compatible with Perl 5.004. -If you removed the B<-w> option from your Perl 5.003 scripts because it -made Perl too verbose, we recommend that you try putting it back when -you upgrade to Perl 5.004. Each new perl version tends to remove some -undesirable warnings, while adding new warnings that may catch bugs in -your scripts. +Starting with Perl 5.004_50 there were many deep and far-reaching changes +to the language internals. If you have dynamically loaded extensions +that you built under perl 5.003 or 5.004, you can continue to use them +with 5.004, but you will need to rebuild and reinstall those extensions +to use them 5.005. See L for detailed instructions on how to +upgrade. -=head2 Deprecated: Inherited C for non-methods +=head2 Default installation structure has changed -Before Perl 5.004, C functions were looked up as methods -(using the C<@ISA> hierarchy), even when the function to be autoloaded -was called as a plain function (e.g. C), not a method -(e.g. Cbar()> or C<$obj->bar()>). +The new Configure defaults are designed to allow a smooth upgrade from +5.004 to 5.005, but you should read L for a detailed +discussion of the changes in order to adapt them to your system. -Perl 5.005 will use method lookup only for methods' Cs. -However, there is a significant base of existing code that may be using -the old behavior. So, as an interim step, Perl 5.004 issues an optional -warning when a non-method uses an inherited C. +=head2 Perl Source Compatibility -The simple rule is: Inheritance will not work when autoloading -non-methods. The simple fix for old code is: In any module that used to -depend on inheriting C for non-methods from a base class named -C, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup. +When none of the experimental features are enabled, there should be +no user-visible Perl source compatibility issue. -=head2 Subroutine arguments created only when they're modified +If threads are enabled, then some caveats apply. C<@_> and C<$_> become +lexical variables. The effect of this should be largely transparent to +the user, but there are some boundary conditions under which user will +need to be aware of the issues. [XXX Add e.g. here.] -In Perl 5.004, nonexistent array and hash elements used as subroutine -parameters are brought into existence only if they are actually -assigned to (via C<@_>). +Some new keywords have been introduced. These are generally expected to +have very little impact on compatibility. See L keyword>, +L keyword>, and L operator>. -Earlier versions of Perl vary in their handling of such arguments. -Perl versions 5.002 and 5.003 always brought them into existence. -Perl versions 5.000, 5.001, and 5.002 brought them into existence only -if they were not the first argument (which was almost certainly a -bug). Earlier versions of Perl never brought them into existence. +Certain barewords are now reserved. Use of these will provoke a warning +if you have asked for them with the C<-w> switch. +See L is now a reserved word>. -For example, given this code: +=head2 C Source Compatibility - undef @a; undef %a; - sub show { print $_[0] }; - sub change { $_[0]++ }; - show($a[2]); - change($a{b}); +=item Core sources now require ANSI C compiler -After this code executes in Perl 5.004, $a{b} exists but $a[2] does -not. In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed -(but $a[2]'s value would have been undefined). +=item Enabling threads has source compatibility issues -=head2 Group vector changeable with C<$)> +=head2 Binary Compatibility -The C<$)> special variable has always (well, in Perl 5, at least) -reflected not only the current effective group, but also the group list -as returned by the C C function (if there is one). -However, until this release, there has not been a way to call the -C C function from Perl. +This version is NOT binary compatible with older versions. All extensions +will need to be recompiled. -In Perl 5.004, assigning to C<$)> is exactly symmetrical with examining -it: The first number in its string value is used as the effective gid; -if there are any numbers after the first one, they are passed to the -C C function (if there is one). +=head2 Security fixes may affect compatibility -=head2 Fixed parsing of $$, &$, etc. +A few taint leaks and taint omissions have been corrected. This may lead +to "failure" of scripts that used to work with older versions. Compiling +with -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changes +to the tainting behavior. But note that the resulting perl will have +known insecurities. -Perl versions before 5.004 misinterpreted any type marker followed by -"$" and a digit. For example, "$$0" was incorrectly taken to mean -"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004. +Oneliners with the C<-e> switch do not create temporary files anymore. -However, the developers of Perl 5.004 could not fix this bug completely, -because at least two widely-used modules depend on the old meaning of -"$$0" in a string. So Perl 5.004 still interprets "$$" in the -old (broken) way inside strings; but it generates this message as a -warning. And in Perl 5.005, this special treatment will cease. +=head2 Relaxed new mandatory warnings introduced in 5.004 -=head2 No resetting of $. on implicit close +Many new warnings that were introduced in 5.004 have been made +optional. Some of these warnings are still present, but perl's new +features make them less often a problem. See L. -The documentation for Perl 5.0 has always stated that C<$.> is I -reset when an already-open file handle is reopened with no intervening -call to C. Due to a bug, perl versions 5.000 through 5.003 -I reset C<$.> under that circumstance; Perl 5.004 does not. +=head2 Licensing -=head2 C may return undef +Perl has a new Social Contract for contributors. See F. -The C operator returns true if a subroutine is expected to -return a list, and false otherwise. In Perl 5.004, C can -also return the undefined value if a subroutine's return value will -not be used at all, which allows subroutines to avoid a time-consuming -calculation of a return value if it isn't going to be used. +The license included in much of the Perl documentation has changed. +[XXX See where?] -=head2 Changes to tainting checks - -A bug in previous versions may have failed to detect some insecure -conditions when taint checks are turned on. (Taint checks are used -in setuid or setgid scripts, or when explicitly turned on with the -C<-T> invocation option.) Although it's unlikely, this may cause a -previously-working script to now fail -- which should be construed -as a blessing, since that indicates a potentially-serious security -hole was just plugged. - -=head2 New Opcode module and revised Safe module - -A new Opcode module supports the creation, manipulation and -application of opcode masks. The revised Safe module has a new API -and is implemented using the new Opcode module. Please read the new -Opcode and Safe documentation. - -=head2 Embedding improvements - -In older versions of Perl it was not possible to create more than one -Perl interpreter instance inside a single process without leaking like a -sieve and/or crashing. The bugs that caused this behavior have all been -fixed. However, you still must take care when embedding Perl in a C -program. See the updated perlembed manpage for tips on how to manage -your interpreters. - -=head2 Internal change: FileHandle class based on IO::* classes - -File handles are now stored internally as type IO::Handle. The -FileHandle module is still supported for backwards compatibility, but -it is now merely a front end to the IO::* modules -- specifically, -IO::Handle, IO::Seekable, and IO::File. We suggest, but do not -require, that you use the IO::* modules in new code. - -In harmony with this change, C<*GLOB{FILEHANDLE}> is now a -backward-compatible synonym for C<*STDOUT{IO}>. - -=head2 Internal change: PerlIO abstraction interface +=head1 Core Changes -It is now possible to build Perl with AT&T's sfio IO package -instead of stdio. See L for more details, and -the F file for how to use it. -=head2 New and changed syntax +=head2 Threads -=over +WARNING: Threading is considered an experimental feature. Details of the +implementation may change without notice. There are known limitations +and and some bugs. -=item $coderef->(PARAMS) +See L. -A subroutine reference may now be suffixed with an arrow and a -(possibly empty) parameter list. This syntax denotes a call of the -referenced subroutine, with the given parameters (if any). +=head2 Compiler -This new syntax follows the pattern of C<$hashref-E{FOO}> and -C<$aryref-E[$foo]>; now, C<&$subref($foo)> may now be written -C<$subref-E($foo)>. All of these arrow terms may be chained; -thus, C<&{$table-E{FOO}}($bar)> may now be written -C<$table-E{FOO}->($bar)>. +WARNING: The Compiler and related tools are considered experimental. +Features may change without notice, and there are known limitations +and bugs. -=back +The Compiler produces three different types of transformations of a +perl program. The C backend generates C code that captures perl's state +just before execution begins. It eliminates the compile-time overheads +of the regular perl interpreter, but the run-time performance remains +comparatively the same. The CC backend generates optimized C code +equivivalent to the code path at run-time. The CC backend has greater +potential for big optimizations, but only a few optimizations are +implemented currently. The Bytecode backend generates a platform +independent bytecode representation of the interpreter's state +just before execution. Thus, the Bytecode back end also eliminates +much of the compilation overhead of the interpreter. -=head2 New and changed builtin constants +The compiler comes with several valuable utilities. -=over +C is an experimental module to detect and warn about suspicious +code, especially the cases that the C<-w> switch does not detect. -=item __PACKAGE__ +C can be used to demystify perl code, and understand +how perl optimizes certain constructs. -The current package name at compile time, or the undefined value if -there is no current package (due to a C directive). Like -C<__FILE__> and C<__LINE__>, C<__PACKAGE__> does I interpolate -into strings. +C generates cross reference reports of all definition and use +of variables, subroutines and formats in a program. -=back +C show the lexical variables used by a subroutine or file +at a glance. -=head2 New and changed builtin variables +C is a simple frontend for compiling perl. -=over +See C. -=item $^E +=head2 Regular Expressions -Extended error message on some platforms. (Also known as -$EXTENDED_OS_ERROR if you C). +See L and L. -=item $^H +=head2 Improved malloc() -The current set of syntax checks enabled by C. See the -documentation of C for more details. Not actually new, but -newly documented. -Because it is intended for internal use by Perl core components, -there is no C long name for this variable. +See banner at the beginning of C for details. -=item $^M +=head2 Quicksort is internally implemented -By default, running out of memory it is not trappable. However, if -compiled for this, Perl may use the contents of C<$^M> as an emergency -pool after die()ing with this message. Suppose that your Perl were -compiled with -DEMERGENCY_SBRK and used Perl's malloc. Then +See C. - $^M = 'a' x (1<<16); +=head2 Reliable signals -would allocate a 64K buffer for use when in emergency. -See the F file for information on how to enable this option. -As a disincentive to casual use of this advanced feature, -there is no C long name for this variable. +Two kinds. -=back +Via C. -=head2 New and changed builtin functions +Via switched runtime op loop. [XXX Not yet available.] -=over +=head2 Reliable stack pointers -=item delete on slices +The internals now reallocate the perl stack only at predictable times. +In particular, magic calls never trigger reallocations of the stack, +because all reentrancy of the runtime is handled using a "stack of stacks". +This should improve reliability of cached stack pointers in the internals +and in XSUBs. -This now works. (e.g. C) +=head2 Behavior of local() on composites is now well-defined -=item flock +See L. -is now supported on more platforms, prefers fcntl to lockf when -emulating, and always flushes before (un)locking. +=head2 C<%!> is transparently tied to the L module -=item printf and sprintf +See L, and L. -Perl now implements these functions itself; it doesn't use the C -library function sprintf() any more, except for floating-point -numbers, and even then only known flags are allowed. As a result, it -is now possible to know which conversions and flags will work, and -what they will do. +=head2 Pseudo-hashes are supported -The new conversions in Perl's sprintf() are: +See L. - %i a synonym for %d - %p a pointer (the address of the Perl value, in hexadecimal) - %n special: B into the next variable in the parameter - list the number of characters printed so far +=head2 C is supported -The new flags that go between the C<%> and the conversion are: +See L. - # prefix octal with "0", hex with "0x" - h interpret integer as C type "short" or "unsigned short" - V interpret integer as Perl's standard integer type +=head2 Slice notation on glob elements is supported -Also, where a number would appear in the flags, an asterisk ("*") may -be used instead, in which case Perl uses the next item in the -parameter list as the given number (that is, as the field width or -precision). If a field width obtained through "*" is negative, it has -the same effect as the '-' flag: left-justification. +[XXX See what?] -See L for a complete list of conversion and flags. +=head2 Keywords can be globally overridden -=item keys as an lvalue +See L. -As an lvalue, C allows you to increase the number of hash buckets -allocated for the given hash. This can gain you a measure of efficiency if -you know the hash is going to get big. (This is similar to pre-extending -an array by assigning a larger number to $#array.) If you say +=head2 C<$^E> is meaningful on Win32 - keys %hash = 200; +See L. -then C<%hash> will have at least 200 buckets allocated for it. These -buckets will be retained even if you do C<%hash = ()>; use C if you want to free the storage while C<%hash> is still in scope. -You can't shrink the number of buckets allocated for the hash using -C in this way (but you needn't worry about doing this by accident, -as trying has no effect). +=head2 C optimized -=item my() in Control Structures +C is now optimized into a counting loop. It does +not try to allocate a 1000000-size list anymore. -You can now use my() (with or without the parentheses) in the control -expressions of control structures such as: +=head2 C can be used as implicitly quoted package name - while (defined(my $line = <>)) { - $line = lc $line; - } continue { - print $line; - } +[XXX See what?] - if ((my $answer = ) =~ /^y(es)?$/i) { - user_agrees(); - } elsif ($answer =~ /^n(o)?$/i) { - user_disagrees(); - } else { - chomp $answer; - die "`$answer' is neither `yes' nor `no'"; - } +=head2 C tests existence of a package -Also, you can declare a foreach loop control variable as lexical by -preceding it with the word "my". For example, in: +[XXX See what?] - foreach my $i (1, 2, 3) { - some_function(); - } +=head2 Better locale support -$i is a lexical variable, and the scope of $i extends to the end of -the loop, but not beyond it. +See L. -Note that you still cannot use my() on global punctuation variables -such as $_ and the like. +=head2 Experimental support for 64-bit platforms -=item pack() and unpack() +Perl5 has always had 64-bit support on systems with 64-bit longs. +Starting with 5.005, the beginnings of experimental support for systems +with 32-bit long and 64-bit 'long long' integers has been added. +If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually +define it in perl.h) then perl will be built with 'long long' support. +There will be many compiler warnings, and the resultant perl may not +work on all systems. There are many other issues related to +third-party extensions and libraries. This option exists to allow +people to work on those issues. -A new format 'w' represents a BER compressed integer (as defined in -ASN.1). Its format is a sequence of one or more bytes, each of which -provides seven bits of the total value, with the most significant -first. Bit eight of each byte is set, except for the last byte, in -which bit eight is clear. +=head2 prototype() returns useful results on builtins -Both pack() and unpack() now fail when their templates contain invalid -types. (Invalid types used to be ignored.) +See L. -=item sysseek() +=head2 Extended support for exception handling -The new sysseek() operator is a variant of seek() that sets and gets the -file's system read/write position, using the lseek(2) system call. It is -the only reliable way to seek before using sysread() or syswrite(). Its -return value is the new position, or the undefined value on failure. +C now accepts a reference value, and C<$@> gets set to that +value in exception traps. This makes it possible to propagate +exception objects. See L. [XXX there's nothing +about this in perlfunc/eval yet.] -=item use VERSION +=head2 Re-blessing in DESTROY() supported for chaining DESTROY() methods -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. Because C occurs at compile time, this check happens -immediately during the compilation process, unlike C, -which waits until runtime for the check. This is often useful if you -need to check the current Perl version before Cing library modules -which have changed in incompatible ways from older versions of Perl. -(We try not to do this more than we have to.) +See L. -=item use Module VERSION LIST +=head2 All C format conversions are handled internally -If the VERSION argument is present between Module and LIST, then the -C 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 -value of the variable $Module::VERSION. (Note that there is not a -comma after VERSION!) +See L. -This version-checking mechanism is similar to the one currently used -in the Exporter module, but it is faster and can be used with modules -that don't use the Exporter. It is the recommended method for new -code. - -=item prototype(FUNCTION) - -Returns the prototype of a function as a string (or C if the -function has no prototype). FUNCTION is a reference to or the name of the -function whose prototype you want to retrieve. -(Not actually new; just never documented before.) +=head2 New C keyword -=item srand - -The default seed for C, which used to be C