This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta.pod - add more docs on %{^HOOK}, update github links,
[perl5.git] / pod / perldelta.pod
... / ...
CommitLineData
1=encoding utf8
2
3=head1 NAME
4
5perldelta - what is new for perl v5.37.10
6
7=head1 DESCRIPTION
8
9This document describes differences between the 5.37.9 release and the 5.37.10
10release.
11
12If you are upgrading from an earlier release such as 5.37.8, first read
13L<perl5379delta>, which describes differences between 5.37.8 and 5.37.9.
14
15=head1 Core Enhancements
16
17=head2 Some C<goto>s are now permitted in C<defer> and C<finally> blocks
18
19Perl version 5.36.0 added C<defer> blocks and permitted the C<finally> keyword
20to also add similar behaviour to C<try>/C<catch> syntax. These did not permit
21any C<goto> expression within the body, as it could have caused control flow
22to jump out of the block. Now, some C<goto> expressions are allowed, if they
23have a constant target label, and that label is found within the block.
24
25 use feature 'defer';
26
27 defer {
28 goto LABEL;
29 print "This does not execute\n";
30 LABEL: print "This does\n";
31 }
32
33=head2 New regexp variable ${^LAST_SUCCESSFUL_PATTERN}
34
35This allows access to the last succesful pattern that matched in the current scope.
36Many aspects of the regex engine refer to the "last successful pattern". The empty
37pattern reuses it, and all of the magic regex vars relate to it. This allows
38access to its pattern. The following code
39
40 if (m/foo/ || m/bar/) {
41 s//PQR/;
42 }
43
44can be rewritten as follows
45
46 if (m/foo/ || m/bar/) {
47 s/${^LAST_SUCCESSFUL_PATTERN}/PQR/;
48 }
49
50and it will do the exactly same thing.
51
52=head2 Deprecation warnings now have specific subcategories
53
54As of 5.37.10 all deprecation warnings will have their own specific
55deprecation category which can be disabled individually. You can see a
56list of all deprecated features in L<perldeprecation>, and in
57L<warnings>. The following list is from L<warnings>:
58
59 +- deprecated ----+
60 | |
61 | +- deprecated::apostrophe_as_package_separator
62 | |
63 | +- deprecated::delimiter_will_be_paired
64 | |
65 | +- deprecated::dot_in_inc
66 | |
67 | +- deprecated::goto_construct
68 | |
69 | +- deprecated::smartmatch
70 | |
71 | +- deprecated::unicode_property_name
72 | |
73 | +- deprecated::version_downgrade
74
75It is still possible to disable all deprecation warnings in a single
76statement with
77
78 no warnings 'deprecated';
79
80but as of 5.37.10 it is possible to have a finer grained control. As
81has historically been the case these warnings are automatically
82enabled with
83
84 use warnings;
85
86=head2 %{^HOOK} API introduced
87
88For various reasons it can be difficult to create subroutine wrappers
89for some of perls keywords. Any keyword which has an undefined
90prototype simply cannot be wrapped with a subroutine, and some keywords
91which perl permits to be wrapped are in practice very tricky to wrap.
92For example C<require> is tricky to wrap, it is possible but doing so
93changes the stack depth, and the standard methods of exporting assume
94that they will be exporting to a package at certain stack depth up the
95stack, and the wrapper will thus change where functions are exported to
96unless implemented with a great deal of care. This can be very awkward
97to deal with.
98
99Accordingly we have introduced a new hash called C<%{^HOOK}> which is
100intended to facilitate such cases. When a keyword supports any kind of
101special hook then the hook will live in this new hash. Hooks in this
102hash will be named after the function they are called by, followed by
103two underbars and then the phase they are executed in, currently either
104before or after the keyword is executed.
105
106In this initial release we support two hooks C<require__before> and
107C<require__after>. These are provided to make it easier to perform tasks
108before and after a require statement.
109
110See L<perlvar> for more details.
111
112=head1 Modules and Pragmata
113
114=head2 Updated Modules and Pragmata
115
116=over 4
117
118=item *
119
120L<Benchmark> has been upgraded from version 1.23 to 1.24.
121
122=item *
123
124L<Class::Struct> has been upgraded from version 0.67 to 0.68.
125
126=item *
127
128L<Config::Perl::V> has been upgraded from version 0.35 to 0.36.
129
130=item *
131
132L<Data::Dumper> has been upgraded from version 2.187 to 2.188.
133
134=item *
135
136L<Digest::SHA> has been upgraded from version 6.03 to 6.04.
137
138=item *
139
140L<Env> has been upgraded from version 1.05 to 1.06.
141
142=item *
143
144L<feature> has been upgraded from version 1.80 to 1.81.
145
146=item *
147
148L<File::Spec> has been upgraded from version 3.88 to 3.89.
149
150=item *
151
152L<Net::Cmd> has been upgraded from version 3.14 to 3.15.
153
154=item *
155
156L<Math::Complex> has been upgraded from version 1.61 to 1.62.
157
158=item *
159
160L<Module::CoreList> has been upgraded from version 5.20230220 to 5.20230320.
161
162=item *
163
164L<overload> has been upgraded from version 1.36 to 1.37.
165
166=item *
167
168L<POSIX> has been upgraded from version 2.11 to 2.12.
169
170=item *
171
172L<Storable> has been upgraded from version 3.29 to 3.31.
173
174=item *
175
176L<Test::Simple> has been upgraded from version 1.302192 to 1.302194.
177
178=item *
179
180L<threads> has been upgraded from version 2.34 to 2.35.
181
182=item *
183
184L<threads::shared> has been upgraded from version 1.65 to 1.67.
185
186=item *
187
188L<Time::HiRes> has been upgraded from version 1.9772 to 1.9774.
189
190=item *
191
192L<warnings> has been upgraded from version 1.62 to 1.63.
193
194=item *
195
196L<XS::APItest> has been upgraded from version 1.30 to 1.32.
197
198=back
199
200=head1 Documentation
201
202=head2 Changes to Existing Documentation
203
204We have attempted to update the documentation to reflect the changes
205listed in this document. If you find any we have missed, open an issue
206at L<https://github.com/Perl/perl5/issues/new/choose>.
207
208Additionally, the following selected changes have been made:
209
210=head3 F<pod/perldebguts.pod>
211
212=over 4
213
214=item *
215
216Updates to regex internals documentation.
217
218=back
219
220=head3 F<pod/perldeprecation.pod>
221
222=over 4
223
224=item *
225
226Added information about unscheduled deprecations and their categories.
227
228=item *
229
230Added category information for existing scheduled deprecations.
231
232=item *
233
234Added smartmatch and apostrophe as a package separator deprecation data.
235
236=back
237
238=head3 F<pod/perlexperiment.pod>
239
240=over 4
241
242=item *
243
244Smartmatch has been moved from experimental status to deprecated status.
245Unfortunately the experiment did not work out.
246
247=back
248
249=head3 F<pod/perlexperiment.pod>
250
251=over 4
252
253=item *
254
255Documented new require hooks.
256
257=back
258
259=head3 F<pod/perlguts.pod>
260
261=over 4
262
263=item *
264
265Documented new magic types C<PERL_MAGIC_destruct>, C<PERL_MAGIC_hook> and
266C<PERL_MAGIC_hookelem>.
267
268=item *
269
270Documented several new or existing save stack macros: C<SAVERCPV()>,
271C<SAVEGENERICSV()>, C<SAVEFREEPV()>, C<SAVEFREERCPV()>
272
273=item *
274
275Documented new mortalization callback macros: C<MORTALSVFUNC_X()>,
276C<MORTALDESTRUCTOR_SV()>
277
278=back
279
280=head3 F<pod/perlop.pod>
281
282=over 4
283
284=item *
285
286Document the behavior of matching the empty pattern better and specify
287its relationship to the new C<${^LAST_SUCCESSFUL_PATTERN}> properly.
288
289=back
290
291=head3 F<pod/perlvar.pod>
292
293=over 4
294
295=item *
296
297Added information on the new C<%{^HOOK}> interface, and the new
298C<require__before> and C<require__after> hooks which it exposes.
299
300=item *
301
302Correct information on the regex variables C<${^PREMATCH}>, C<${^MATCH}>
303and C<${^POSTMATCH}>, all of which were incorrectly documented due to an
304oversight. Specifically they only work properly after a regex operation
305that used the /p modifier to enable them.
306
307=item *
308
309Added information on the new regex variable C<${^LAST_SUCCESSFUL_PATTERN}>,
310which represents the pattern of the last successful regex match in scope.
311
312=back
313
314=head1 Diagnostics
315
316The following additions or changes have been made to diagnostic output,
317including warnings and fatal error messages. For the complete list of
318diagnostic messages, see L<perldiag>.
319
320=head2 New Diagnostics
321
322=head3 New Errors
323
324=over 4
325
326=item *
327
328L<${^HOOK}{%s} may only be a CODE reference or undef|perldiag/"${^HOOK}{%s} may only be a CODE reference or undef">
329
330=item *
331
332L<Attempt to set unknown hook '%s' in %{^HOOK}|perldiag/"Attempt to set unknown hook '%s' in %{^HOOK}">
333
334=item *
335
336L<Missing or undefined argument to %s via %{^HOOK}{require__before}|perldiag/"Missing or undefined argument to %s via %{^HOOK}{require__before}">
337
338=item *
339
340L<Too many capture groups (limit is %d) in regex mE<sol>%sE<sol>|perldiag/"Too many capture groups (limit is %d) in regex m/%s/">
341
342=back
343
344=head3 New Warnings
345
346=over 4
347
348=item *
349
350L<Can't call destructor for 0x%p in global destruction|perldiag/"Can't call destructor for 0x%p in global destruction">
351
352=back
353
354=head2 Changes to Existing Diagnostics
355
356=over 4
357
358=item *
359
360L<given is deprecated|perldiag/"given is deprecated"> replaces C<given is experimental>.
361
362=item *
363
364L<when is deprecated|perldiag/"when is deprecated"> replaces C<when is experimental>.
365
366=item *
367
368L<Smartmatch is deprecated|perldiag/"Smartmatch is deprecated"> replaces C<Smartmatch is experimental>.
369
370=back
371
372=head1 Testing
373
374Tests were added and changed to reflect the other additions and
375changes in this release. Furthermore, these significant changes were
376made:
377
378=over 4
379
380=item *
381
382Added t/op/hook/ for testing C<%{^HOOK}> related functionality. Specifically
383the F<t/op/hook/require.t> for testing the new require hooks.
384
385=item *
386
387Added F<t/op/deprecation.t> to test that our deprecation policies are being
388followed properly.
389
390=item *
391
392Fixed bugs in F<t/harness> and F<t/TEST> that meant that tests in F<t/test_pl> and
393F<t/class> were not being run during normal testing.
394
395=back
396
397=head2 Platform-Specific Notes
398
399=over 4
400
401=item Windows
402
403=over 4
404
405=item *
406
407C<POSIX::dup2> no longer creates broken sockets. [L<GH #20920|https://github.com/Perl/perl5/issues/20920>]
408
409=item *
410
411Closing a busy pipe could cause Perl to hang. [L<GH #19963|https://github.com/Perl/perl5/issues/19963>]
412
413=back
414
415=back
416
417=head1 Internal Changes
418
419=over 4
420
421=item *
422
423Added C<SAVERCPV()> and C<SAVEFREERCPV()> for better support for working
424with C<RCPV> (reference counted string/pointer value) structures which
425currently are used in opcodes to share filename and warning bit data in
426a memory efficient manner.
427
428=item *
429
430Added C<MORTALSVFUNC_SV()> and C<MORTALDESTRUCTOR_SV()> macros, which
431make it possible to create a destructor which is fired at the end of
432the current statement. This uses the C<PERL_MAGIC_destruct> magic to
433use "free" magic to trigger an action when a variable is freed. The
434action can be specified as a C function or as a Perl code reference.
435
436=item *
437
438Added the C<%{^HOOK}> api and related C<PERL_MAGIC_hook> and
439C<PERL_MAGIC_hookelem> for providing ways to hook selected perl functions
440which for one reason or another are problematic to wrap with a customized
441subroutine.
442
443=item *
444
445Added support for C<${^HOOK}{require__before}> which can be used to
446rewrite the filename that C<require> will try to load, and also to block
447C<require> from loading a specific module, even via fully qualified
448filename. The hook can also be used to perform "pre-require" and
449"post-require" actions.
450
451=item *
452
453Added support for C<${^HOOK}{require__after}> which can be used to
454track what modules have been required after the fact.
455
456=item *
457
458Regular expression opcodes (regops) now use a standardized structure
459layout that uses unions to expose data in different format. This means
460it should be much easier to extend or modify regops to use more memory.
461This has been used to make a number of regops track how many parens
462they contain.
463
464=back
465
466=head1 Selected Bug Fixes
467
468=over 4
469
470=item *
471
472In the new experimental C<class> feature, attributes are no longer a syntax
473error when using the unit class syntax.
474[L<GH #20888|https://github.com/Perl/perl5/issues/20888>].
475
476=item *
477
478A number of bugs related to capture groups in quantified groups in regular
479expression have been fixed, especially in alternations. For example in
480a pattern like:
481
482 "foobazfoobar" =~ /((foo)baz|foo(bar))+/
483
484the regex variable C<$2> will not be "foo" as it once was, it will be undef.
485
486=item *
487
488Bugs with regex backreference operators that are inside of a capture
489group have been fixed. For instance:
490
491 "xa=xaaa" =~ /^(xa|=?\1a){2}\z/
492
493will now correctly not match. [L<GH #10073|https://github.com/Perl/perl5/issues/10073>]
494
495=item *
496
497C<SSGROW()> and C<SSCHECK()> have been reworked to ensure that the requested
498space is actually allocated. C<SSCHECK()> is now an alias for C<SSGROW()>.
499
500=back
501
502=head1 Acknowledgements
503
504Perl 5.37.10 represents approximately 4 weeks of development since Perl
5055.37.9 and contains approximately 23,000 lines of changes across 360 files
506from 21 authors.
507
508Excluding auto-generated files, documentation and release tools, there were
509approximately 6,000 lines of changes to 220 .pm, .t, .c and .h files.
510
511Perl continues to flourish into its fourth decade thanks to a vibrant
512community of users and developers. The following people are known to have
513contributed the improvements that became Perl 5.37.10:
514
515Arne Johannessen, Craig A. Berry, Dan Jacobson, David Mitchell, Elvin
516Aslanov, Graham Knop, James E Keenan, James Raspass, Jon Gentle, Karen
517Etheridge, Karl Williamson, Leon Timmermans, Lukas Mai, Paul Evans, Philippe
518Bruhat (BooK), Richard Leach, Steve Hay, Tomasz Konojacki, Tony Cook, Yves
519Orton, Zefram.
520
521The list above is almost certainly incomplete as it is automatically
522generated from version control history. In particular, it does not include
523the names of the (very much appreciated) contributors who reported issues to
524the Perl bug tracker.
525
526Many of the changes included in this version originated in the CPAN modules
527included in Perl's core. We're grateful to the entire CPAN community for
528helping Perl to flourish.
529
530For a more complete list of all of Perl's historical contributors, please
531see the F<AUTHORS> file in the Perl source distribution.
532
533=head1 Reporting Bugs
534
535If you find what you think is a bug, you might check the perl bug database
536at L<https://github.com/Perl/perl5/issues>. There may also be information at
537L<http://www.perl.org/>, the Perl Home Page.
538
539If you believe you have an unreported bug, please open an issue at
540L<https://github.com/Perl/perl5/issues>. Be sure to trim your bug down to a
541tiny but sufficient test case.
542
543If the bug you are reporting has security implications which make it
544inappropriate to send to a public issue tracker, then see
545L<perlsec/SECURITY VULNERABILITY CONTACT INFORMATION>
546for details of how to report the issue.
547
548=head1 Give Thanks
549
550If you wish to thank the Perl 5 Porters for the work we had done in Perl 5,
551you can do so by running the C<perlthanks> program:
552
553 perlthanks
554
555This will send an email to the Perl 5 Porters list with your show of thanks.
556
557=head1 SEE ALSO
558
559The F<Changes> file for an explanation of how to view exhaustive details on
560what changed.
561
562The F<INSTALL> file for how to build Perl.
563
564The F<README> file for general stuff.
565
566The F<Artistic> and F<Copying> files for copyright information.
567
568=cut