patch@2009-05-25.21:50:08 perl5db.t leaves db.out behind on VMS
[p5sagit/p5-mst-13.2.git] / pod / perl5110delta.pod
CommitLineData
7120b314 1=head1 NAME
2
3perldelta - what is new for perl v5.11.0
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.10.0 and the 5.11.0
9948897e 8development releases.
7120b314 9
10=head1 Incompatible Changes
11
8b8da387 12=head2 Switch statement changes
13
14The handling of complex expressions by the C<given>/C<when> switch
15statement has been enhanced. There are three new cases where C<when> now
16inteprets its argument as a boolean, instead of an expression to be used
17in a smart match:
18
19=over 4
20
21=item file tests
22
23File tests that return a boolean value (that excludes C<-s>, C<-M>, C<-A>,
24and C<-C>):
25
26 when (-f $file) { say "$file is a file" }
27
28=item flip-flop operators
29
30The C<..> and C<...> flip-flop operators are evaluated in boolean context,
31following their usual semantics; see L<perlop/"Range Operators">.
32
33=item defined-or operator
34
35A compound expression involving the defined-or operator, as in
36C<when (expr1 // expr2)>, will be treated as boolean if the first
37expression is boolean. (This just extends the existing rule that applies
38to the regular or operator, as in C<when (expr1 || expr2)>.)
39
40=back
41
42The next paragraph details more changes brought to the semantics to
43the smart match operator, that naturally also modify the behaviour
44of the switch statements where smart matching is implicitly used.
45
46=head2 Smart match changes
47
48=head3 Changes to type-based dispatch
49
50The smart match operator C<~~> is no longer commutative. The behaviour of
51a smart match now depends primarily on the type of its right hand
52argument. While the general backwards compatibility is maintained,
53several changes must be noted:
54
55=over 4
56
57=item *
58
59Code references with an empty prototype are no longer treated specially.
60They are passed an argument like the other code references (even if they
61choose to ignore it).
62
63=item *
64
65C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine
66returns a true value for each key of the hash (resp. element of the
67array), instead of passing the whole hash or array as a reference to
68the subroutine.
69
70=item *
71
72C<undef ~~ %hash> is always false (since C<undef> can't be a key in a
73hash). No implicit conversion to C<""> is done (as was the case in perl
745.10.0).
75
76=item *
77
78C<$scalar ~~ @array> now always distributes the smart match across the
79elements of the array. It's true if one element in @array verifies
80C<$scalar ~~ $element>. This is a generalization of the old behaviour
81that tested whether the array contained the scalar.
82
83=back
84
85The full dispatch table for the smart match operator is given in
86L<perlsyn/"Smart matching in detail">.
87
88=head3 Smart match and overloading
89
90According to the rule of dispatch based on the rightmost argument type,
91when an object overloading C<~~> appears on the right side of the
92operator, the overload routine will always be called (with a 3rd argument
93set to a true value, see L<overload>.) However, when the object will
94appear on the left, the overload routine will be called only when the
95rightmost argument is a scalar. This way distributivity of smart match
96across arrays is not broken, as well as the other behaviours with complex
97types (coderefs, hashes, regexes). Thus, writers of overloading routines
98for smart match need to worry only with comparing against a scalar, and
99possibly with stringification overloading; the other cases will be
100automatically handled consistently.
101
102C<~~> will now refuse to work on objects that do not overload it (in order
103to avoid relying on the object's underlying structure).
104
7120b314 105=head1 Core Enhancements
106
1839a850 107=head1 The C<overloading> pragma
108
109This pragma allows you to lexically disable or enable overloading
110for some or all operations. (Yuval Kogman)
111
7120b314 112=head1 Modules and Pragmata
113
1839a850 114=head2 Pragmata Changes
115
116=over 4
117
118=item C<overloading>
119
120See L</"The C<overloading> pragma"> above.
121
122=back
123
7120b314 124=head1 Utility Changes
125
126=head1 Documentation
127
128=head1 Performance Enhancements
129
130=head1 Installation and Configuration Improvements
131
132=head1 Selected Bug Fixes
133
54ad55c5 134=over 4
135
136=item C<-I> on shebang line now adds directories in front of @INC
137
138as documented, and as does C<-I> when specified on the command-line.
139(Renée Bäcker)
140
141=back
142
7120b314 143=head1 New or Changed Diagnostics
144
145=head1 Changed Internals
146
147=head1 Known Problems
148
149=head2 Platform Specific Problems
150
151=head1 Reporting Bugs
152
153If you find what you think is a bug, you might check the articles
154recently posted to the comp.lang.perl.misc newsgroup and the perl
155bug database at http://bugs.perl.org/ . There may also be
156information at http://www.perl.org/ , the Perl Home Page.
157
158If you believe you have an unreported bug, please run the B<perlbug>
159program included with your release. Be sure to trim your bug down
160to a tiny but sufficient test case. Your bug report, along with the
161output of C<perl -V>, will be sent off to perlbug@perl.org to be
162analysed by the Perl porting team.
163
164=head1 SEE ALSO
165
166The F<Changes> file for exhaustive details on what changed.
167
168The F<INSTALL> file for how to build Perl.
169
170The F<README> file for general stuff.
171
172The F<Artistic> and F<Copying> files for copyright information.
173
174=cut