source: trunk/essentials/dev-lang/perl/pod/perl5005delta.pod

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 33.5 KB
Line 
1=head1 NAME
2
3perl5005delta - what's new for perl5.005
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.004 release and this one.
8
9=head1 About the new versioning system
10
11Perl is now developed on two tracks: a maintenance track that makes
12small, safe updates to released production versions with emphasis on
13compatibility; and a development track that pursues more aggressive
14evolution. Maintenance releases (which should be considered production
15quality) have subversion numbers that run from C<1> to C<49>, and
16development releases (which should be considered "alpha" quality) run
17from C<50> to C<99>.
18
19Perl 5.005 is the combined product of the new dual-track development
20scheme.
21
22=head1 Incompatible Changes
23
24=head2 WARNING: This version is not binary compatible with Perl 5.004.
25
26Starting with Perl 5.004_50 there were many deep and far-reaching changes
27to the language internals. If you have dynamically loaded extensions
28that you built under perl 5.003 or 5.004, you can continue to use them
29with 5.004, but you will need to rebuild and reinstall those extensions
30to use them 5.005. See F<INSTALL> for detailed instructions on how to
31upgrade.
32
33=head2 Default installation structure has changed
34
35The new Configure defaults are designed to allow a smooth upgrade from
365.004 to 5.005, but you should read F<INSTALL> for a detailed
37discussion of the changes in order to adapt them to your system.
38
39=head2 Perl Source Compatibility
40
41When none of the experimental features are enabled, there should be
42very few user-visible Perl source compatibility issues.
43
44If threads are enabled, then some caveats apply. C<@_> and C<$_> become
45lexical variables. The effect of this should be largely transparent to
46the user, but there are some boundary conditions under which user will
47need to be aware of the issues. For example, C<local(@_)> results in
48a "Can't localize lexical variable @_ ..." message. This may be enabled
49in a future version.
50
51Some new keywords have been introduced. These are generally expected to
52have very little impact on compatibility. See L<New C<INIT> keyword>,
53L<New C<lock> keyword>, and L<New C<qrE<sol>E<sol>> operator>.
54
55Certain barewords are now reserved. Use of these will provoke a warning
56if you have asked for them with the C<-w> switch.
57See L<C<our> is now a reserved word>.
58
59=head2 C Source Compatibility
60
61There have been a large number of changes in the internals to support
62the new features in this release.
63
64=over 4
65
66=item *
67
68Core sources now require ANSI C compiler
69
70An ANSI C compiler is now B<required> to build perl. See F<INSTALL>.
71
72=item *
73
74All Perl global variables must now be referenced with an explicit prefix
75
76All Perl global variables that are visible for use by extensions now
77have a C<PL_> prefix. New extensions should C<not> refer to perl globals
78by their unqualified names. To preserve sanity, we provide limited
79backward compatibility for globals that are being widely used like
80C<sv_undef> and C<na> (which should now be written as C<PL_sv_undef>,
81C<PL_na> etc.)
82
83If you find that your XS extension does not compile anymore because a
84perl global is not visible, try adding a C<PL_> prefix to the global
85and rebuild.
86
87It is strongly recommended that all functions in the Perl API that don't
88begin with C<perl> be referenced with a C<Perl_> prefix. The bare function
89names without the C<Perl_> prefix are supported with macros, but this
90support may cease in a future release.
91
92See L<perlapi>.
93
94=item *
95
96Enabling threads has source compatibility issues
97
98Perl built with threading enabled requires extensions to use the new
99C<dTHR> macro to initialize the handle to access per-thread data.
100If you see a compiler error that talks about the variable C<thr> not
101being declared (when building a module that has XS code), you need
102to add C<dTHR;> at the beginning of the block that elicited the error.
103
104The API function C<perl_get_sv("@",FALSE)> should be used instead of
105directly accessing perl globals as C<GvSV(errgv)>. The API call is
106backward compatible with existing perls and provides source compatibility
107with threading is enabled.
108
109See L<"C Source Compatibility"> for more information.
110
111=back
112
113=head2 Binary Compatibility
114
115This version is NOT binary compatible with older versions. All extensions
116will need to be recompiled. Further binaries built with threads enabled
117are incompatible with binaries built without. This should largely be
118transparent to the user, as all binary incompatible configurations have
119their own unique architecture name, and extension binaries get installed at
120unique locations. This allows coexistence of several configurations in
121the same directory hierarchy. See F<INSTALL>.
122
123=head2 Security fixes may affect compatibility
124
125A few taint leaks and taint omissions have been corrected. This may lead
126to "failure" of scripts that used to work with older versions. Compiling
127with -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changes
128to the tainting behavior. But note that the resulting perl will have
129known insecurities.
130
131Oneliners with the C<-e> switch do not create temporary files anymore.
132
133=head2 Relaxed new mandatory warnings introduced in 5.004
134
135Many new warnings that were introduced in 5.004 have been made
136optional. Some of these warnings are still present, but perl's new
137features make them less often a problem. See L<New Diagnostics>.
138
139=head2 Licensing
140
141Perl has a new Social Contract for contributors. See F<Porting/Contract>.
142
143The license included in much of the Perl documentation has changed.
144Most of the Perl documentation was previously under the implicit GNU
145General Public License or the Artistic License (at the user's choice).
146Now much of the documentation unambiguously states the terms under which
147it may be distributed. Those terms are in general much less restrictive
148than the GNU GPL. See L<perl> and the individual perl manpages listed
149therein.
150
151=head1 Core Changes
152
153
154=head2 Threads
155
156WARNING: Threading is considered an B<experimental> feature. Details of the
157implementation may change without notice. There are known limitations
158and some bugs. These are expected to be fixed in future versions.
159
160See F<README.threads>.
161
162=head2 Compiler
163
164WARNING: The Compiler and related tools are considered B<experimental>.
165Features may change without notice, and there are known limitations
166and bugs. Since the compiler is fully external to perl, the default
167configuration will build and install it.
168
169The Compiler produces three different types of transformations of a
170perl program. The C backend generates C code that captures perl's state
171just before execution begins. It eliminates the compile-time overheads
172of the regular perl interpreter, but the run-time performance remains
173comparatively the same. The CC backend generates optimized C code
174equivalent to the code path at run-time. The CC backend has greater
175potential for big optimizations, but only a few optimizations are
176implemented currently. The Bytecode backend generates a platform
177independent bytecode representation of the interpreter's state
178just before execution. Thus, the Bytecode back end also eliminates
179much of the compilation overhead of the interpreter.
180
181The compiler comes with several valuable utilities.
182
183C<B::Lint> is an experimental module to detect and warn about suspicious
184code, especially the cases that the C<-w> switch does not detect.
185
186C<B::Deparse> can be used to demystify perl code, and understand
187how perl optimizes certain constructs.
188
189C<B::Xref> generates cross reference reports of all definition and use
190of variables, subroutines and formats in a program.
191
192C<B::Showlex> show the lexical variables used by a subroutine or file
193at a glance.
194
195C<perlcc> is a simple frontend for compiling perl.
196
197See C<ext/B/README>, L<B>, and the respective compiler modules.
198
199=head2 Regular Expressions
200
201Perl's regular expression engine has been seriously overhauled, and
202many new constructs are supported. Several bugs have been fixed.
203
204Here is an itemized summary:
205
206=over 4
207
208=item Many new and improved optimizations
209
210Changes in the RE engine:
211
212 Unneeded nodes removed;
213 Substrings merged together;
214 New types of nodes to process (SUBEXPR)* and similar expressions
215 quickly, used if the SUBEXPR has no side effects and matches
216 strings of the same length;
217 Better optimizations by lookup for constant substrings;
218 Better search for constants substrings anchored by $ ;
219
220Changes in Perl code using RE engine:
221
222 More optimizations to s/longer/short/;
223 study() was not working;
224 /blah/ may be optimized to an analogue of index() if $& $` $' not seen;
225 Unneeded copying of matched-against string removed;
226 Only matched part of the string is copying if $` $' were not seen;
227
228=item Many bug fixes
229
230Note that only the major bug fixes are listed here. See F<Changes> for others.
231
232 Backtracking might not restore start of $3.
233 No feedback if max count for * or + on "complex" subexpression
234 was reached, similarly (but at compile time) for {3,34567}
235 Primitive restrictions on max count introduced to decrease a
236 possibility of a segfault;
237 (ZERO-LENGTH)* could segfault;
238 (ZERO-LENGTH)* was prohibited;
239 Long REs were not allowed;
240 /RE/g could skip matches at the same position after a
241 zero-length match;
242
243=item New regular expression constructs
244
245The following new syntax elements are supported:
246
247 (?<=RE)
248 (?<!RE)
249 (?{ CODE })
250 (?i-x)
251 (?i:RE)
252 (?(COND)YES_RE|NO_RE)
253 (?>RE)
254 \z
255
256=item New operator for precompiled regular expressions
257
258See L<New C<qrE<sol>E<sol>> operator>.
259
260=item Other improvements
261
262 Better debugging output (possibly with colors),
263 even from non-debugging Perl;
264 RE engine code now looks like C, not like assembler;
265 Behaviour of RE modifiable by `use re' directive;
266 Improved documentation;
267 Test suite significantly extended;
268 Syntax [:^upper:] etc., reserved inside character classes;
269
270=item Incompatible changes
271
272 (?i) localized inside enclosing group;
273 $( is not interpolated into RE any more;
274 /RE/g may match at the same position (with non-zero length)
275 after a zero-length match (bug fix).
276
277=back
278
279See L<perlre> and L<perlop>.
280
281=head2 Improved malloc()
282
283See banner at the beginning of C<malloc.c> for details.
284
285=head2 Quicksort is internally implemented
286
287Perl now contains its own highly optimized qsort() routine. The new qsort()
288is resistant to inconsistent comparison functions, so Perl's C<sort()> will
289not provoke coredumps any more when given poorly written sort subroutines.
290(Some C library C<qsort()>s that were being used before used to have this
291problem.) In our testing, the new C<qsort()> required the minimal number
292of pair-wise compares on average, among all known C<qsort()> implementations.
293
294See C<perlfunc/sort>.
295
296=head2 Reliable signals
297
298Perl's signal handling is susceptible to random crashes, because signals
299arrive asynchronously, and the Perl runtime is not reentrant at arbitrary
300times.
301
302However, one experimental implementation of reliable signals is available
303when threads are enabled. See C<Thread::Signal>. Also see F<INSTALL> for
304how to build a Perl capable of threads.
305
306=head2 Reliable stack pointers
307
308The internals now reallocate the perl stack only at predictable times.
309In particular, magic calls never trigger reallocations of the stack,
310because all reentrancy of the runtime is handled using a "stack of stacks".
311This should improve reliability of cached stack pointers in the internals
312and in XSUBs.
313
314=head2 More generous treatment of carriage returns
315
316Perl used to complain if it encountered literal carriage returns in
317scripts. Now they are mostly treated like whitespace within program text.
318Inside string literals and here documents, literal carriage returns are
319ignored if they occur paired with linefeeds, or get interpreted as whitespace
320if they stand alone. This behavior means that literal carriage returns
321in files should be avoided. You can get the older, more compatible (but
322less generous) behavior by defining the preprocessor symbol
323C<PERL_STRICT_CR> when building perl. Of course, all this has nothing
324whatever to do with how escapes like C<\r> are handled within strings.
325
326Note that this doesn't somehow magically allow you to keep all text files
327in DOS format. The generous treatment only applies to files that perl
328itself parses. If your C compiler doesn't allow carriage returns in
329files, you may still be unable to build modules that need a C compiler.
330
331=head2 Memory leaks
332
333C<substr>, C<pos> and C<vec> don't leak memory anymore when used in lvalue
334context. Many small leaks that impacted applications that embed multiple
335interpreters have been fixed.
336
337=head2 Better support for multiple interpreters
338
339The build-time option C<-DMULTIPLICITY> has had many of the details
340reworked. Some previously global variables that should have been
341per-interpreter now are. With care, this allows interpreters to call
342each other. See the C<PerlInterp> extension on CPAN.
343
344=head2 Behavior of local() on array and hash elements is now well-defined
345
346See L<perlsub/"Temporary Values via local()">.
347
348=head2 C<%!> is transparently tied to the L<Errno> module
349
350See L<perlvar>, and L<Errno>.
351
352=head2 Pseudo-hashes are supported
353
354See L<perlref>.
355
356=head2 C<EXPR foreach EXPR> is supported
357
358See L<perlsyn>.
359
360=head2 Keywords can be globally overridden
361
362See L<perlsub>.
363
364=head2 C<$^E> is meaningful on Win32
365
366See L<perlvar>.
367
368=head2 C<foreach (1..1000000)> optimized
369
370C<foreach (1..1000000)> is now optimized into a counting loop. It does
371not try to allocate a 1000000-size list anymore.
372
373=head2 C<Foo::> can be used as implicitly quoted package name
374
375Barewords caused unintuitive behavior when a subroutine with the same
376name as a package happened to be defined. Thus, C<new Foo @args>,
377use the result of the call to C<Foo()> instead of C<Foo> being treated
378as a literal. The recommended way to write barewords in the indirect
379object slot is C<new Foo:: @args>. Note that the method C<new()> is
380called with a first argument of C<Foo>, not C<Foo::> when you do that.
381
382=head2 C<exists $Foo::{Bar::}> tests existence of a package
383
384It was impossible to test for the existence of a package without
385actually creating it before. Now C<exists $Foo::{Bar::}> can be
386used to test if the C<Foo::Bar> namespace has been created.
387
388=head2 Better locale support
389
390See L<perllocale>.
391
392=head2 Experimental support for 64-bit platforms
393
394Perl5 has always had 64-bit support on systems with 64-bit longs.
395Starting with 5.005, the beginnings of experimental support for systems
396with 32-bit long and 64-bit 'long long' integers has been added.
397If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually
398define it in perl.h) then perl will be built with 'long long' support.
399There will be many compiler warnings, and the resultant perl may not
400work on all systems. There are many other issues related to
401third-party extensions and libraries. This option exists to allow
402people to work on those issues.
403
404=head2 prototype() returns useful results on builtins
405