This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lexer API fixes
[perl5.git] / pod / perl593delta.pod
CommitLineData
496c75d0
RGS
1=head1 NAME
2
70693193 3perl593delta - what is new for perl v5.9.3
496c75d0
RGS
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.9.2 and the 5.9.3
d7f8936a 8development releases. See L<perl590delta>, L<perl591delta> and
496c75d0
RGS
9L<perl592delta> for the differences between 5.8.0 and 5.9.2.
10
11=head1 Incompatible Changes
12
2770530f
RGS
13=head2 Parsing of C<-f _>
14
35cdf2f9
RGS
15The identifier C<_> is now forced to be a bareword after a filetest
16operator. This solves a number of misparsing issues when a global C<_>
17subroutine is defined.
2770530f 18
78ef48ad
RGS
19=head2 C<mkdir()>
20
21C<mkdir()> without arguments now defaults to C<$_>.
22
23=head2 Magic goto and eval
24
25The construct C<eval { goto &foo }> is now disallowed. (Note that the
26similar construct, but with C<eval("")> instead, was already forbidden.)
27
28=head2 C<$#> has been removed
29
30The deprecated C<$#> variable (output format for numbers) has been
31removed. A new warning, C<$# is no longer supported>, has been added.
32
33=head2 C<:unique>
34
8f7e634e 35The C<:unique> attribute has been made a no-op, since its current
78ef48ad
RGS
36implementation was fundamentally flawed and not threadsafe.
37
e603cea9
RGS
38=head2 Scoping of the C<sort> pragma
39
40The C<sort> pragma is now lexically scoped. Its effect used to be global.
41
496c75d0
RGS
42=head1 Core Enhancements
43
e603cea9
RGS
44=head2 The C<feature> pragma
45
46The C<feature> pragma is used to enable new syntax that would break Perl's
35cdf2f9 47backwards-compatibility with older releases of the language. It's a lexical
e603cea9
RGS
48pragma, like C<strict> or C<warnings>.
49
50Currently the following new features are available: C<switch> (adds a
51switch statement), C<~~> (adds a Perl 6-like smart match operator), C<say>
52(adds a C<say> built-in function), and C<err> (adds an C<err> keyword).
53Those features are described below.
54
55Note that C<err> low-precedence defined-or operator used to be enabled by
35cdf2f9
RGS
56default (although as a weak keyword, meaning that any function would
57override it). It's now only recognized when explicitly turned on (and is
58then a regular keyword).
59
60Those features, and the C<feature> pragma itself, have been contributed by
61Robin Houston.
e603cea9 62
78ef48ad
RGS
63=head2 Switch and Smart Match operator
64
35cdf2f9
RGS
65Perl 5 now has a switch statement. It's available when C<use feature
66'switch'> is in effect. This feature introduces three new keywords,
a8ca0236 67C<given>, C<when>, and C<default>:
35cdf2f9
RGS
68
69 given ($foo) {
70 when (/^abc/) { $abc = 1; }
71 when (/^def/) { $def = 1; }
72 when (/^xyz/) { $xyz = 1; }
73 default { $nothing = 1; }
74 }
75
76A more complete description of how Perl matches the switch variable
77against the C<when> conditions is given in L<perlsyn/"Switch statements">.
78
79This kind of match is called I<smart match>, and it's also possible to use
80it outside of switch statements, via the new C<~~> operator (enabled via
81the C<use feature '~~'> directive). See L<perlsyn/"Smart matching in
82detail">.
e603cea9 83
78ef48ad
RGS
84=head2 C<say()>
85
409c2c5b 86say() is a new built-in, only available when C<use feature 'say'> is in
e603cea9
RGS
87effect, that is similar to print(), but that implicitly appends a newline
88to the printed string. See L<perlfunc/say>.
89
78ef48ad
RGS
90=head2 C<CLONE_SKIP()>
91
92Perl has now support for the C<CLONE_SKIP> special subroutine. Like
93C<CLONE>, C<CLONE_SKIP> is called once per package; however, it is called
94just before cloning starts, and in the context of the parent thread. If it
95returns a true value, then no objects of that class will be cloned. See
35cdf2f9 96L<perlmod> for details. (Contributed by Dave Mitchell.)
78ef48ad
RGS
97
98=head2 C<${^CHILD_ERROR_NATIVE}>
99
100A new internal variable, C<${^CHILD_ERROR_NATIVE}>, gives the native
101status returned by the last pipe close, backtick command, successful call
102to wait() or waitpid(), or from the system() operator. See L<perlrun> for
35cdf2f9 103details. (Contributed by Gisle Aas.)
78ef48ad
RGS
104
105=head2 Assertions
106
107The support for assertions, introduced in perl 5.9.0, has been improved.
108The syntax for the C<-A> command-line switch has changed; it now accepts
109an optional module name, defaulting to C<assertions::activate>. See
35cdf2f9 110L<assertions> and L<perlrun>. (Contributed by Salvador Fandiño García.)
78ef48ad
RGS
111
112=head2 Unicode Character Database 4.1.0
113
114The copy of the Unicode Character Database included in Perl 5.9 has
115been updated to 4.1.0.
116
8f7e634e
RGS
117=head2 C<no VERSION>
118
119You can now use C<no> followed by a version number to specify that you
c986422f 120want to use a version of perl older than the specified one.
8f7e634e 121
e603cea9
RGS
122=head2 Recursive sort subs
123
ebab5fdd 124You can now use recursive subroutines with sort(), thanks to Robin Houston.
e603cea9
RGS
125
126=head2 Effect of pragmas in eval
127
128The compile-time value of the C<%^H> hint variable can now propagate into
129eval("")uated code. This makes it more useful to implement lexical
130pragmas.
131
132As a side-effect of this, the overloaded-ness of constants now propagates
133into eval("").
134
135=head2 New B<-E> command-line switch
136
137B<-E> is equivalent to B<-e>, but it implicitly enables all
35cdf2f9 138optional features (like C<use feature ":5.10">).
e603cea9 139
ebab5fdd
RGS
140=head2 C<chdir>, C<chmod> and C<chown> on filehandles
141
142C<chdir>, C<chmod> and C<chown> can now work on filehandles as well as
143filenames, if the system supports respectively C<fchdir>, C<fchmod> and
144C<fchown>, thanks to a patch provided by Gisle Aas.
145
35cdf2f9
RGS
146=head2 OS groups
147
148C<$(> and C<$)> now return groups in the order where the OS returns them,
149thanks to Gisle Aas. This wasn't previously the case.
150
496c75d0
RGS
151=head1 Modules and Pragmata
152
35cdf2f9
RGS
153=head2 New Core Modules
154
155=over 4
156
157=item *
158
159A new pragma, C<feature>, has been added; see above in L</"Core
160Enhancements">.
161
162=item *
163
a8ca0236 164C<assertions::compat>, also available on CPAN, allows the use of assertions on
35cdf2f9
RGS
165perl versions prior to 5.9.0 (that is the first one to natively support
166them).
167
168=item *
169
170C<Math::BigInt::FastCalc> is an XS-enabled, and thus faster, version of
171C<Math::BigInt::Calc>.
172
173=item *
174
175C<Compress::Zlib> is an interface to the zlib compression library. It
176comes with a bundled version of zlib, so having a working zlib is not a
177prerequisite to install it. It's used by C<Archive::Tar> (see below).
178
179=item *
78ef48ad 180
35cdf2f9 181C<IO::Zlib> is an C<IO::>-style interface to C<Compress::Zlib>.
e603cea9 182
35cdf2f9 183=item *
78ef48ad 184
35cdf2f9 185C<Archive::Tar> is a module to manipulate C<tar> archives.
78ef48ad 186
35cdf2f9 187=item *
78ef48ad 188
35cdf2f9
RGS
189C<Digest::SHA> is a module used to calculate many types of SHA digests,
190has been included for SHA support in the CPAN module.
78ef48ad 191
473aa102
RGS
192=item *
193
194C<ExtUtils::CBuilder> and C<ExtUtils::ParseXS> have been added.
195
35cdf2f9 196=back
78ef48ad 197
496c75d0
RGS
198=head1 Utility Changes
199
78ef48ad
RGS
200=head2 C<ptar>
201
35cdf2f9
RGS
202C<ptar> is a pure perl implementation of C<tar>, that comes with
203C<Archive::Tar>.
204
8716aee0
RGS
205=head2 C<ptardiff>
206
207C<ptardiff> is a small script used to generate a diff between the contents
208of a tar archive and a directory tree. Like C<ptar>, it comes with
209C<Archive::Tar>.
210
35cdf2f9
RGS
211=head2 C<shasum>
212
213This command-line utility, used to print or to check SHA digests, comes
214with the new C<Digest::SHA> module.
215
216=head2 C<h2xs> enhancements
217
a8ca0236 218C<h2xs> implements a new option C<--use-xsloader> to force use of
35cdf2f9
RGS
219C<XSLoader> even in backwards compatible modules.
220
221The handling of authors' names that had apostrophes has been fixed.
222
223Any enums with negative values are now skipped.
224
225=head2 C<perlivp> enhancements
226
409c2c5b
NC
227C<perlivp> no longer checks for F<*.ph> files by default. Use the new C<-a>
228option to run I<all> tests.
35cdf2f9 229
496c75d0
RGS
230=head1 Documentation
231
8f7e634e
RGS
232=head2 Perl Glossary
233
234The L<perlglossary> manpage is a glossary of terms used in the Perl
35cdf2f9 235documentation, technical and otherwise, kindly provided by O'Reilly Media,
a8ca0236 236Inc.
8f7e634e 237
cd8b8377
RGS
238L<perltodo> now lists a rough roadmap to Perl 5.10.
239
496c75d0
RGS
240=head1 Performance Enhancements
241
e603cea9
RGS
242=head2 XS-assisted SWASHGET
243
244Some pure-perl code that perl was using to retrieve Unicode properties and
ffabe59c 245transliteration mappings has been reimplemented in XS.
e603cea9 246
35cdf2f9 247=head2 Constant subroutines
e603cea9 248
e761a786
NC
249The interpreter internals now support a far more memory efficient form of
250inlineable constants. Storing a reference to a constant value in a symbol
251table is equivalent to a full typeglob referencing a constant subroutine,
252but using about 400 bytes less memory. This proxy constant subroutine is
253automatically upgraded to a real typeglob with subroutine if necessary.
254The approach taken is analogous to the existing space optimisation for
255subroutine stub declarations, which are stored as plain scalars in place
256of the full typeglob.
257
258Several of the core modules have been converted to use this feature for
259their system dependent constants - as a result C<use POSIX;> now takes about
260200K less memory.
e603cea9 261
ebab5fdd
RGS
262=head2 C<PERL_DONT_CREATE_GVSV>
263
264The new compilation flag C<PERL_DONT_CREATE_GVSV>, introduced as an option
265in perl 5.8.8, is turned on by default in perl 5.9.3. It prevents perl
4cd37d19 266from creating an empty scalar with every new typeglob. See L<perl589delta>
ebab5fdd
RGS
267for details.
268
269=head2 Weak references are cheaper
270
271Weak reference creation is now I<O(1)> rather than I<O(n)>, courtesy of
272Nicholas Clark. Weak reference deletion remains I<O(n)>, but if deletion only
273happens at program exit, it may be skipped completely.
274
275=head2 sort() enhancements
276
277Salvador Fandiño provided improvements to reduce the memory usage of C<sort>
278and to speed up some cases.
279
496c75d0
RGS
280=head1 Installation and Configuration Improvements
281
35cdf2f9
RGS
282=head2 Compilation improvements
283
284Parallel makes should work properly now, although there may still be problems
285if C<make test> is instructed to run in parallel.
286
287Building with Borland's compilers on Win32 should work more smoothly. In
288particular Steve Hay has worked to side step many warnings emitted by their
289compilers and at least one C compiler internal error.
290
291Perl extensions on Windows now can be statically built into the Perl DLL,
292thanks to a work by Vadim Konovalov.
293
78ef48ad
RGS
294=head2 New Or Improved Platforms
295
296Perl is being ported to Symbian OS. See L<perlsymbian> for more
297information.
298
e603cea9
RGS
299The VMS port has been improved. See L<perlvms>.
300
301DynaLoader::dl_unload_file() now works on Windows.
302
303Portability of Perl on various recent compilers on Windows has been
304improved (Borland C++, Visual C++ 7.0).
305
306=head2 New probes
307
35cdf2f9
RGS
308C<Configure> will now detect C<clearenv> and C<unsetenv>, thanks to a
309patch from Alan Burlison. It will also probe for C<futimes> (and use it
310internally if available), and whether C<sprintf> correctly returns the
311length of the formatted string.
e603cea9 312
78ef48ad
RGS
313=head2 Module auxiliary files
314
315README files and changelogs for CPAN modules bundled with perl are no
316longer installed.
317
496c75d0
RGS
318=head1 Selected Bug Fixes
319
2e6a7e23
RGS
320=head2 C<defined $$x>
321
322C<use strict "refs"> was ignoring taking a hard reference in an argument
323to defined(), as in :
324
325 use strict "refs";
326 my $x = "foo";
327 if (defined $$x) {...}
328
329This now correctly produces the run-time error C<Can't use string as a
330SCALAR ref while "strict refs" in use>. (However, C<defined @$foo> and
331C<defined %$foo> are still allowed. Those constructs are discouraged
332anyway.)
333
e603cea9
RGS
334=head2 Calling CORE::require()
335
336CORE::require() and CORE::do() were always parsed as require() and do()
409c2c5b 337when they were overridden. This is now fixed.
e603cea9
RGS
338
339=head2 Subscripts of slices
340
341You can now use a non-arrowed form for chained subscripts after a list
342slice, like in:
343
344 ({foo => "bar"})[0]{foo}
345
346This used to be a syntax error; a C<< -> >> was required.
347
348=head2 Remove over-optimisation
349
350Perl 5.9.2 introduced a change so that assignments of C<undef> to a
351scalar, or of an empty list to an array or a hash, were optimised out. As
352this could cause problems when C<goto> jumps were involved, this change
353was backed out.
354
355=head2 sprintf() fixes
356
357Using the sprintf() function with some formats could lead to a buffer
358overflow in some specific cases. This has been fixed, along with several
cd8b8377 359other bugs, notably in bounds checking.
e603cea9 360
35cdf2f9
RGS
361In related fixes, it was possible for badly written code that did not follow
362the documentation of C<Sys::Syslog> to have formatting vulnerabilities.
363C<Sys::Syslog> has been changed to protect people from poor quality third
364party code.
365
366=head2 no warnings 'category' works correctly with -w
367
368Previously when running with warnings enabled globally via C<-w>, selective
369disabling of specific warning categories would actually turn off all warnings.
370This is now fixed; now C<no warnings 'io';> will only turn off warnings in the
371C<io> class. Previously it would erroneously turn off all warnings.
e603cea9 372
78ef48ad
RGS
373=head2 Smaller fixes
374
375=over 4
376
377=item *
378
379C<FindBin> now works better with directories where access rights are more
380restrictive than usual.
381
382=item *
383
e603cea9
RGS
384Several memory leaks in ithreads were closed. Also, ithreads were made
385less memory-intensive.
78ef48ad
RGS
386
387=item *
388
ebab5fdd
RGS
389Trailing spaces are now trimmed from C<$!> and C<$^E>.
390
391=item *
392
393Operations that require perl to read a process' list of groups, such as reads
394of C<$(> and C<$)>, now dynamically allocate memory rather than using a
395fixed sized array. The fixed size array could cause C stack exhaustion on
396systems configured to use large numbers of groups.
397
398=item *
399
78ef48ad
RGS
400C<PerlIO::scalar> now works better with non-default C<$/> settings.
401
402=item *
403
cd8b8377
RGS
404The C<x> repetition operator is now able to operate on C<qw//> lists. This
405used to raise a syntax error.
78ef48ad 406
e603cea9
RGS
407=item *
408
409The debugger now traces correctly execution in eval("")uated code that
410contains #line directives.
411
412=item *
413
414The value of the C<open> pragma is no longer ignored for three-argument
415opens.
416
417=item *
418
ebab5fdd
RGS
419Perl will now use the C library calls C<unsetenv> and C<clearenv> if present
420to delete keys from C<%ENV> and delete C<%ENV> entirely, thanks to a patch
421from Alan Burlison.
e603cea9 422
78ef48ad
RGS
423=back
424
425=head2 More Unicode Fixes
426
427=over 4
428
429=item *
430
431chr() on a negative value now gives C<\x{FFFD}>, the Unicode replacement
432character, unless when the C<bytes> pragma is in effect, where the low
433eight bytes of the value are used.
434
ebab5fdd
RGS
435=item *
436
437Some case insensitive matches between UTF-8 encoded data and 8 bit regexps,
438and vice versa, could give malformed character warnings. These have been
439fixed by Dave Mitchell and Yves Orton.
440
441=item *
442
443C<lcfirst> and C<ucfirst> could corrupt the string for certain cases where
444the length UTF-8 encoding of the string in lower case, upper case or title
445case differed. This was fixed by Nicholas Clark.
446
78ef48ad
RGS
447=back
448
496c75d0
RGS
449=head1 New or Changed Diagnostics
450
78ef48ad
RGS
451=head2 Attempt to set length of freed array
452
453This is a new warning, produced in situations like the following one:
454
455 $r = do {my @a; \$#a};
456 $$r = 503;
457
35cdf2f9
RGS
458=head2 Non-string passed as bitmask
459
460This is a new warning, produced when number has been passed as a argument to
461select(), instead of a bitmask.
462
463 # Wrong, will now warn
464 $rin = fileno(STDIN);
465 ($nfound,$timeleft) = select($rout=$rin, undef, undef, $timeout);
466
467 # Should be
468 $rin = '';
469 vec($rin,fileno(STDIN),1) = 1;
470 ($nfound,$timeleft) = select($rout=$rin, undef, undef, $timeout);
471
78ef48ad
RGS
472=head2 Search pattern not terminated or ternary operator parsed as search pattern
473
474This syntax error indicates that the lexer couldn't find the final
475delimiter of a C<?PATTERN?> construct. Mentioning the ternary operator in
476this error message makes syntax diagnostic easier.
477
8f7e634e
RGS
478=head2 "%s" variable %s masks earlier declaration
479
480This warning is now emitted in more consistent cases; in short, when one
481of the declarations involved is a C<my> variable:
482
483 my $x; my $x; # warns
484 my $x; our $x; # warns
485 our $x; my $x; # warns
486
a8ca0236 487On the other hand, the following:
8f7e634e
RGS
488
489 our $x; our $x;
490
491now gives a C<"our" variable %s redeclared> warning.
492
e603cea9
RGS
493=head2 readdir()/closedir()/etc. attempted on invalid dirhandle
494
495These new warnings are now emitted when a dirhandle is used but is
496either closed or not really a dirhandle.
497
496c75d0
RGS
498=head1 Changed Internals
499
35cdf2f9
RGS
500In general, the source code of perl has been refactored, tied up, and
501optimized in many places. Also, memory management and allocation has been
502improved in a couple of points.
503
504Andy Lester supplied many improvements to determine which function
505parameters and local variables could actually be declared C<const> to the C
506compiler. Steve Peters provided new C<*_set> macros and reworked the core to
507use these rather than assigning to macros in LVALUE context.
508
509Dave Mitchell improved the lexer debugging output under C<-DT>.
78ef48ad 510
e603cea9
RGS
511A new file, F<mathoms.c>, has been added. It contains functions that are
512no longer used in the perl core, but that remain available for binary or
513source compatibility reasons. However, those functions will not be
ffabe59c 514compiled in if you add C<-DNO_MATHOMS> in the compiler flags.
78ef48ad
RGS
515
516The C<AvFLAGS> macro has been removed.
517
ebab5fdd
RGS
518The C<av_*()> functions, used to manipulate arrays, no longer accept null
519C<AV*> parameters.
520
78ef48ad
RGS
521=head2 B:: modules inheritance changed
522
523The inheritance hierarchy of C<B::> modules has changed; C<B::NV> now
524inherits from C<B::SV> (it used to inherit from C<B::IV>).
525
496c75d0
RGS
526=head1 Reporting Bugs
527
528If you find what you think is a bug, you might check the articles
529recently posted to the comp.lang.perl.misc newsgroup and the perl
530bug database at http://bugs.perl.org/ . There may also be
531information at http://www.perl.org/ , the Perl Home Page.
532
533If you believe you have an unreported bug, please run the B<perlbug>
534program included with your release. Be sure to trim your bug down
535to a tiny but sufficient test case. Your bug report, along with the
536output of C<perl -V>, will be sent off to perlbug@perl.org to be
537analysed by the Perl porting team.
538
539=head1 SEE ALSO
540
541The F<Changes> file for exhaustive details on what changed.
542
543The F<INSTALL> file for how to build Perl.
544
545The F<README> file for general stuff.
546
547The F<Artistic> and F<Copying> files for copyright information.
548
549=cut