Run the main tests "slowest first" by ordering the rules correctly.
[p5sagit/p5-mst-13.2.git] / pod / perl5110delta.pod
1 =head1 NAME
2
3 perldelta - what is new for perl v5.11.0
4
5 =head1 DESCRIPTION
6
7 This document describes differences between the 5.10.0 and the 5.11.0
8 development releases.
9
10 =head1 Incompatible Changes
11
12 =head2 Switch statement changes
13
14 The handling of complex expressions by the C<given>/C<when> switch
15 statement has been enhanced. There are two new cases where C<when> now
16 interprets its argument as a boolean, instead of an expression to be used
17 in a smart match:
18
19 =over 4
20
21 =item flip-flop operators
22
23 The C<..> and C<...> flip-flop operators are now evaluated in boolean
24 context, following their usual semantics; see L<perlop/"Range Operators">.
25
26 Note that, as in perl 5.10.0, C<when (1..10)> will not work to test
27 whether a given value is an integer between 1 and 10; you should use
28 C<when ([1..10])> instead (note the array reference).
29
30 However, contrary to 5.10.0, evaluating the flip-flop operators in boolean
31 context ensures it can now be useful in a C<when()>, notably for
32 implementing bistable conditions, like in:
33
34     when (/^=begin/ .. /^=end/) { ... }
35
36 =item defined-or operator
37
38 A compound expression involving the defined-or operator, as in
39 C<when (expr1 // expr2)>, will be treated as boolean if the first
40 expression is boolean. (This just extends the existing rule that applies
41 to the regular or operator, as in C<when (expr1 || expr2)>.)
42
43 =back
44
45 The next section details more changes brought to the semantics to
46 the smart match operator, that naturally also modify the behaviour
47 of the switch statements where smart matching is implicitly used.
48
49 =head2 Smart match changes
50
51 =head3 Changes to type-based dispatch
52
53 The smart match operator C<~~> is no longer commutative. The behaviour of
54 a smart match now depends primarily on the type of its right hand
55 argument. Moreover, its semantics has been adjusted for greater
56 consistency or usefulness in several cases. While the general backwards
57 compatibility is maintained, several changes must be noted:
58
59 =over 4
60
61 =item *
62
63 Code references with an empty prototype are no longer treated specially.
64 They are passed an argument like the other code references (even if they
65 choose to ignore it).
66
67 =item *
68
69 C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine
70 returns a true value for each key of the hash (or element of the
71 array), instead of passing the whole hash or array as a reference to
72 the subroutine.
73
74 =item *
75
76 Due to the commutativity breakage, code references are no longer
77 treated specially when appearing on the left of the C<~~> operator,
78 but like any vulgar scalar.
79
80 =item *
81
82 C<undef ~~ %hash> is always false (since C<undef> can't be a key in a
83 hash). No implicit conversion to C<""> is done (as was the case in perl
84 5.10.0).
85
86 =item *
87
88 C<$scalar ~~ @array> now always distributes the smart match across the
89 elements of the array. It's true if one element in @array verifies
90 C<$scalar ~~ $element>. This is a generalization of the old behaviour
91 that tested whether the array contained the scalar.
92
93 =back
94
95 The full dispatch table for the smart match operator is given in
96 L<perlsyn/"Smart matching in detail">.
97
98 =head3 Smart match and overloading
99
100 According to the rule of dispatch based on the rightmost argument type,
101 when an object overloading C<~~> appears on the right side of the
102 operator, the overload routine will always be called (with a 3rd argument
103 set to a true value, see L<overload>.) However, when the object will
104 appear on the left, the overload routine will be called only when the
105 rightmost argument is a simple scalar. This way distributivity of smart match
106 across arrays is not broken, as well as the other behaviours with complex
107 types (coderefs, hashes, regexes). Thus, writers of overloading routines
108 for smart match mostly need to worry only with comparing against a scalar,
109 and possibly with stringification overloading; the other common cases
110 will be automatically handled consistently.
111
112 C<~~> will now refuse to work on objects that do not overload it (in order
113 to avoid relying on the object's underlying structure). (However, if the
114 object overloads the stringification or the numification operators, and
115 if overload fallback is active, it will be used instead, as usual.)
116
117 =head2 Labels can't be keywords
118
119 Labels used as targets for the C<goto>, C<last>, C<next> or C<redo>
120 statements cannot be keywords anymore. This restriction will prevent
121 potential confusion between the C<goto LABEL> and C<goto EXPR> syntaxes:
122 for example, a statement like C<goto print> would jump to a label whose
123 name would be the return value of print(), (usually 1), instead of a
124 label named C<print>. Moreover, the other control flow statements
125 would just ignore any keyword passed to them as a label name. Since
126 such labels cannot be defined anymore, this kind of error will be
127 avoided.
128
129 =head1 Core Enhancements
130
131 =head2 The C<overloading> pragma
132
133 This pragma allows you to lexically disable or enable overloading
134 for some or all operations. (Yuval Kogman)
135
136 =head2 C<\N> regex escape
137
138 A new regex escape has been added, C<\N>. It will match any character that
139 is not a newline, independently from the presence or absence of the single
140 line match modifier C</s>. (If C<\N> is followed by an opening brace and
141 by a letter, perl will still assume that a Unicode character name is
142 coming, so compatibility is preserved.) (Rafael Garcia-Suarez)
143
144 =head2 Implicit strictures
145
146 Using the C<use VERSION> syntax with a version number greater or equal
147 to 5.11.0 will also lexically enable strictures just like C<use strict>
148 would do (in addition to enabling features.) So, the following:
149
150     use 5.11.0;
151
152 will now imply:
153
154     use strict;
155     use feature ':5.11';
156
157 =head2 Parallel tests
158
159 The core distribution can now run its regression tests in parallel on
160 Unix-like platforms. Instead of running C<make test>, set C<TEST_JOBS> in
161 your environment to the number of tests to run in parallel, and run
162 C<make test_harness>. On a Bourne-like shell, this can be done as
163
164     TEST_JOBS=3 make test_harness  # Run 3 tests in parallel
165
166 An environment variable is used, rather than parallel make itself, because
167 L<TAP::Harness> needs to be able to schedule individual non-conflicting test
168 scripts itself, and there is no standard interface to C<make> utilities to
169 interact with their job schedulers.
170
171 =head2 The C<...> operator
172
173 A new operator, C<...>, nicknamed the Yada Yada operator, has been added.
174 It is intended to mark placeholder code, that is not yet implemented.
175 See L<perlop/"Yada Yada Operator">. (chromatic)
176
177 =head1 Modules and Pragmata
178
179 =head2 Pragmata Changes
180
181 =over 4
182
183 =item C<overloading>
184
185 See L</"The C<overloading> pragma"> above.
186
187 =back
188
189 =head2 Selected Changes to Core Modules
190
191 =over 4
192
193 L<Carp> now includes all the necessary code to function. Previously, it
194 used to be a lightweight placeholder that loaded the actual code from
195 C<Carp::Heavy> on demand. C<Carp::Heavy> is now a simple, empty module
196 kept for backwards compatibility for programs that used to pre-load it.
197
198 =back
199
200 =head1 Utility Changes
201
202 =head1 Documentation
203
204 =head1 Performance Enhancements
205
206 =head1 Installation and Configuration Improvements
207
208 =head1 Selected Bug Fixes
209
210 =over 4
211
212 =item C<-I> on shebang line now adds directories in front of @INC
213
214 as documented, and as does C<-I> when specified on the command-line.
215 (Renée Bäcker)
216
217 =item C<kill> is now fatal when called on non-numeric process identifiers
218
219 Previously, an 'undef' process identifier would be interpreted as a request to
220 kill process "0", which would terminate the current process group on POSIX
221 systems.  Since process identifiers are always integers, killing a non-numeric
222 process is now fatal.
223
224 =item C<-C> on the shebang line is once more permitted
225
226 if it is also specified on the command line. C<-C> on the shebang line used
227 to be a silent no-op I<if> it was not also on the command line, so perl 
228 5.10.0 disallowed it, which broke some scripts. Now perl checks whether it 
229 is also on the command line and only dies if it is not.
230
231 =back
232
233 =head1 New or Changed Diagnostics
234
235 =head1 Changed Internals
236
237 =head1 Known Problems
238
239 =head2 Platform Specific Problems
240
241 =head1 Reporting Bugs
242
243 If you find what you think is a bug, you might check the articles
244 recently posted to the comp.lang.perl.misc newsgroup and the perl
245 bug database at http://bugs.perl.org/ .  There may also be
246 information at http://www.perl.org/ , the Perl Home Page.
247
248 If you believe you have an unreported bug, please run the B<perlbug>
249 program included with your release.  Be sure to trim your bug down
250 to a tiny but sufficient test case.  Your bug report, along with the
251 output of C<perl -V>, will be sent off to perlbug@perl.org to be
252 analysed by the Perl porting team.
253
254 If the bug you are reporting has security implications, which make it
255 inappropriate to send to a publicly archived mailing list, then please send
256 it to perl5-security-report@perl.org. This points to a closed subscription
257 unarchived mailing list, which includes all the core committers, who be able
258 to help assess the impact of issues, figure out a resolution, and help
259 co-ordinate the release of patches to mitigate or fix the problem across all
260 platforms on which Perl is supported. Please only use this address for security
261 issues in the Perl core, not for modules independently distributed on CPAN.
262
263 =head1 SEE ALSO
264
265 The F<Changes> file for exhaustive details on what changed.
266
267 The F<INSTALL> file for how to build Perl.
268
269 The F<README> file for general stuff.
270
271 The F<Artistic> and F<Copying> files for copyright information.
272
273 =cut