This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add created_as_... builtins to perldelta
[perl5.git] / pod / perl5359delta.pod
CommitLineData
d84985bf
RB
1=encoding utf8
2
3=head1 NAME
4
5perl5359delta - what is new for perl v5.35.9
6
7=head1 DESCRIPTION
8
9This document describes differences between the 5.35.8 release and the 5.35.9
10release.
11
12If you are upgrading from an earlier release such as 5.35.7, first read
13L<perl5358delta>, which describes differences between 5.35.7 and 5.35.8.
14
15=head1 Core Enhancements
16
17=head2 Subroutine signatures are no longer experimental
18
19Introduced in Perl version 5.20.0, and modified several times since, the
20subroutine signatures feature (C<use feature 'signatures'>) is now no longer
21considered experimental. It is now considered a stable language feature and
22is included in the C<:5.36> feature bundle, enabled automatically by
23C<use v5.36>, and no longer prints a warning.
24
25 use v5.36;
26
27 sub add ($x, $y) {
28 return $x + $y;
29 }
30
31Despite this, certain elements of signatured subroutines remain
32experimental; see below.
33
34=head2 @_ is now experimental within signatured subs
35
36Even though subroutine signatures are now stable, use of the default arguments
37array (C<@_>) with a subroutine that has a signature remains experimental,
38with its own warning category. Silencing the C<experimental::signatures>
39warning category is not sufficient to dismiss this. The new warning is
40emitted with the category name C<experimental::args_array_with_signatures>.
41
42Any subroutine that has a signature and tries to make use of the defaults
43argument array or an element thereof (C<@_> or C<$_[INDEX]>), either
44explicitly or implicitly (such as C<shift> or C<pop> with no argument) will
45provoke a warning at compile-time:
46
47 use v5.36;
48
49 sub f ($x, $y = 123) {
50 say "The first argument is $_[0]";
51 }
52
53Z<>
54
55 Use of @_ in array element with signatured subroutine is experimental
56 at file.pl line 4.
57
58The behaviour of code which attempts to do this is no longer specified, and
59may be subject to change in a future version.
60
61=head2 The C<isa> operator is no longer experimental
62
63Introduced in Perl version 5.32.0, this operator has remained unchanged
64since then. The operator is now considered a stable language feature and is
65included in the C<:5.36> feature bundle, enabled automatically by
66C<use v5.36>.
67
68For more detail see L<perlop/Class Instance Operator>.
69
70=head2 -g command-line flag
71
72A new command-line flag, -g, is available. It is a simpler alias for -0777.
73
74For more information, see L<perlrun/-g>.
75
76=head1 Deprecations
77
78=head2 Downgrading a C<use VERSION> statement to below v5.11
79
80Attempting to issue a second C<use VERSION> statement that requests a version
81lower than C<v5.11> when an earlier statement that requested a version at
82least C<v5.11> has already been seen, will now print a deprecation warning.
83
84For example:
85
86 use v5.14;
87 say "The say statement is permitted";
88 use v5.8; # This will print a warning
89 print "We must use print\n";
90
91This is because of an intended related change to the interaction between
92C<use VERSION> and C<use strict>. If you specify a version >= 5.11, strict is
93enabled implicitly. If you request a version < 5.11, strict will become
94disabled I<even if you had previously written> C<use strict>. This was not
95the previous behaviour of C<use VERSION>, which at present will track
96explicitly-enabled strictness flags independently.
97
98Code which wishes to mix versions in this manner should use lexical scoping
99with block syntax to ensure that the differently versioned regions remain
100lexically isolated.
101
102 {
103 use v5.14;
104 say "The say statement is permitted";
105 }
106 {
107 use v5.8; # No warning is emitted
108 print "We must use print\n";
109 }
110
111=head1 Modules and Pragmata
112
113=head2 Updated Modules and Pragmata
114
115=over 4
116
117=item *
118
119L<B::Deparse> has been upgraded from version 1.61 to 1.62.
120
121=item *
122
123L<charnames> has been upgraded from version 1.49 to 1.50.
124
125=item *
126
127L<CPAN> has been upgraded from version 2.29 to 2.33.
128
129=item *
130
131L<Devel::PPPort> has been upgraded from version 3.63 to 3.64.
132
133=item *
134
135L<experimental> has been upgraded from version 0.025 to 0.027.
136
137=item *
138
139L<feature> has been upgraded from version 1.69 to 1.70.
140
141=item *
142
143L<File::Copy> has been upgraded from version 2.38 to 2.39.
144
145=item *
146
147L<Hash::Util> has been upgraded from version 0.27 to 0.28.
148
149=item *
150
151L<Hash::Util::FieldHash> has been upgraded from version 1.25 to 1.26.
152
153=item *
154
155L<Module::CoreList> has been upgraded from version 5.20220120 to 5.20220220.
156
157=item *
158
159L<Opcode> has been upgraded from version 1.55 to 1.56.
160
161=item *
162
163L<overload> has been upgraded from version 1.34 to 1.35.
164
165=item *
166
167L<re> has been upgraded from version 0.41 to 0.42.
168
169=item *
170
171L<Scalar::Util> has been upgraded from version 1.60 to 1.61.
172
173=item *
174
175L<sigtrap> has been upgraded from version 1.09 to 1.10.
176
177=item *
178
179L<Tie::SubstrHash> has been upgraded from version 1.00 to 1.01.
180
181=item *
182
183L<warnings> has been upgraded from version 1.56 to 1.57.
184
185=item *
186
187L<XS::APItest> has been upgraded from version 1.20 to 1.21.
188
189=back
190
191=head1 Diagnostics
192
193=head2 New Diagnostics
194
195=head3 New Warnings
196
197=over 4
198
199=item *
200
201L<Built-in function '%s' is experimental|perldiag/"Built-in function '%s' is experimental">
202
203A call is being made to a function in the
204C<builtin::> namespace, which is currently experimental.
205
206=item *
207
208L<Implicit use of @_ in %s with signatured subroutine is experimental|perldiag/"Implicit use of @_ in %s with signatured subroutine is experimental">
209
210An expression that implicitly involves the C<@_> arguments array was found in
211a subroutine that uses a signature.
212
213=item *
214
215L<Use of @_ in %s with signatured subroutine is experimental|perldiag/"Use of @_ in %s with signatured subroutine is experimental">
216
217An expression involving the C<@_> arguments array was found in a subroutine that uses a signature.
218
219=item *
220
221L<Downgrading a use VERSION declaration to below v5.11 is deprecated|perldiag/"Downgrading a use VERSION declaration to below v5.11 is deprecated">
222
223This warning is emitted on a C<use VERSION> statement that
224requests a version below v5.11 (when the effects of C<use strict> would be
225disabled), after a previous declaration of one having a larger number (which
226would have enabled these effects)
227
228=back
229
230=head2 Changes to Existing Diagnostics
231
232=over 4
233
234=item *
235
236L<Subroutine %s redefined|perldiag/"Subroutine %s redefined">
237
238Localized subroutine redefinitions no longer trigger this warning.
239
240=back
241
242=head1 Internal Changes
243
244=over 4
245
246=item *
247
248New equality-test functions C<sv_numeq> and C<sv_streq> have been added, along
249with C<..._flags>-suffixed variants. These expose a simple and consistent API
250to perform numerical or string comparison which is aware of operator
251overloading.
252
253=item *
254
255Reading the string form of an integer value no longer sets the flag C<SVf_POK>.
256The string form is still cached internally, and still re-read directly by the
257macros C<SvPV(sv)> I<etc> (inline, without calling a C function). XS code that
258already calls the APIs to get values will not be affected by this change. XS
259code that accesses flags directly instead of using API calls to express its
260intent I<might> break, but such code likely is already buggy if passed some
261other values, such as floating point values or objects with string overloading.
262
263This small change permits code (such as JSON serializers) to reliably determine
264between
265
266=over 4
267
268=item *
269
270a value that was initially B<written> as an integer, but then B<read> as a string
271
272 my $answer = 42;
273 print "The answer is $answer\n";
274
275=item *
276
277that same value that was initially B<written> as a string, but then B<read> as an integer
278
279 my $answer = "42";
280 print "That doesn't look right\n"
281 unless $answer == 6 * 9;
282
283=back
284
285For the first case (originally written as an integer), we now have:
286
287 use Devel::Peek;
288 my $answer = 42;
289 Dump ($answer);
290 my $void = "$answer";
291 print STDERR "\n";
292 Dump($answer)
293
294
295 SV = IV(0x562538925778) at 0x562538925788
296 REFCNT = 1
297 FLAGS = (IOK,pIOK)
298 IV = 42
299
300 SV = PVIV(0x5625389263c0) at 0x562538925788
301 REFCNT = 1
302 FLAGS = (IOK,pIOK,pPOK)
303 IV = 42
304 PV = 0x562538919b50 "42"\0
305 CUR = 2
306 LEN = 10
307
308For the second (originally written as a string), we now have:
309
310 use Devel::Peek;
311 my $answer = "42";
312 Dump ($answer);
313 my $void = $answer == 6 * 9;
314 print STDERR "\n";
315 Dump($answer)'
316
317
318 SV = PV(0x5586ffe9bfb0) at 0x5586ffec0788
319 REFCNT = 1
320 FLAGS = (POK,IsCOW,pPOK)
321 PV = 0x5586ffee7fd0 "42"\0
322 CUR = 2
323 LEN = 10
324 COW_REFCNT = 1
325
326 SV = PVIV(0x5586ffec13c0) at 0x5586ffec0788
327 REFCNT = 1
328 FLAGS = (IOK,POK,IsCOW,pIOK,pPOK)
329 IV = 42
330 PV = 0x5586ffee7fd0 "42"\0
331 CUR = 2
332 LEN = 10
333 COW_REFCNT = 1
334
335(One can't rely on the presence or absence of the flag C<SVf_IsCOW> to
336determine the history of operations on a scalar.)
337
338Previously both cases would be indistinguishable, with all 4 flags set:
339
340 SV = PVIV(0x55d4d62edaf0) at 0x55d4d62f0930
341 REFCNT = 1
342 FLAGS = (IOK,POK,pIOK,pPOK)
343 IV = 42
344 PV = 0x55d4d62e1740 "42"\0
345 CUR = 2
346 LEN = 10
347
348(and possibly C<SVf_IsCOW>, but not always)
349
350This now means that if XS code I<really> needs to determine which form a value
351was first written as, it should implement logic roughly
352
353 if (flags & SVf_IOK|SVf_NOK) && !(flags & SVf_POK)
354 serialize as number
355 else if (flags & SVf_POK)
356 serialize as string
357 else
358 the existing guesswork ...
359
360Note that this doesn't cover "dualvars" - scalars that report different
361values when asked for their string form or number form (such as C<$!>).
362Most serialization formats cannot represent such duplicity.
363
364I<The existing guesswork> remains because as well as dualvars, values might
365be C<undef>, references, overloaded references, typeglobs and other things that
366Perl itself can represent but do not map one-to-one into external formats, so
367need some amount of approximation or encapsulation.
368
369=item *
370
371Memory for hash iterator state (C<struct xpvhv_aux>) is now allocated as part
372of the hash body, instead of as part of the block of memory allocated for the
373main hash array.
374
375Nothing else changes - memory for this structure is still allocated only when
376needed, is still accessed via the C<HvAUX()> macro, and the macro should only
377be called when C<SvOOK()> is true. Hashes are still always of type C<SVt_PVHV>,
378hash bodies are still allocated from arenas, and the address of the hash
379doesn't change, because the address is the pointer to the head structure, which
380never moves.
381
382Internally, a second arena (the arena with index 1) is used to allocate larger
383bodies with space for C<struct xpvhv_aux>, the body "upgraded", and the "head"
384structure updated to reflect this (much the same way that the bodies of scalars
385are upgraded). We already re-purpose arenas - arena with index 0 is used for
386C<HE *>s.
387
388None of this affects documented public XS interfaces. The only code changes are
389in F<hv.c> and F<sv.c>. As the rest of the core itself uses these macros but
390needed no changes, likely no code on CPAN will be affected either.
391
392=back
393
394=head1 Acknowledgements
395
396Perl 5.35.9 represents approximately 4 weeks of development since Perl
3975.35.8 and contains approximately 8,700 lines of changes across 280 files
398from 22 authors.
399
400Excluding auto-generated files, documentation and release tools, there were
401approximately 3,000 lines of changes to 110 .pm, .t, .c and .h files.
402
403Perl continues to flourish into its fourth decade thanks to a vibrant
404community of users and developers. The following people are known to have
405contributed the improvements that became Perl 5.35.9:
406
407Branislav Zahradník, Christopher Yeleighton, Dagfinn Ilmari MannsÄker,
408Dave Cross, David Cantrell, Hugo van der Sanden, James E Keenan, James
409Raspass, Karl Williamson, Leon Timmermans, Max Maischein, Michiel Beijen,
410Nicholas Clark, Nicolas R., Paul Evans, Renee Baecker, Ricardo Signes,
411Sergey Zhmylove, TAKAI Kousuke, Tomasz Konojacki, Tony Cook, Yves Orton.
412
413The list above is almost certainly incomplete as it is automatically
414generated from version control history. In particular, it does not include
415the names of the (very much appreciated) contributors who reported issues to
416the Perl bug tracker.
417
418Many of the changes included in this version originated in the CPAN modules
419included in Perl's core. We're grateful to the entire CPAN community for
420helping Perl to flourish.
421
422For a more complete list of all of Perl's historical contributors, please
423see the F<AUTHORS> file in the Perl source distribution.
424
425=head1 Reporting Bugs
426
427If you find what you think is a bug, you might check the perl bug database
428at L<https://github.com/Perl/perl5/issues>. There may also be information at
429L<http://www.perl.org/>, the Perl Home Page.
430
431If you believe you have an unreported bug, please open an issue at
432L<https://github.com/Perl/perl5/issues>. Be sure to trim your bug down to a
433tiny but sufficient test case.
434
435If the bug you are reporting has security implications which make it
436inappropriate to send to a public issue tracker, then see
437L<perlsec/SECURITY VULNERABILITY CONTACT INFORMATION>
438for details of how to report the issue.
439
440=head1 Give Thanks
441
442If you wish to thank the Perl 5 Porters for the work we had done in Perl 5,
443you can do so by running the C<perlthanks> program:
444
445 perlthanks
446
447This will send an email to the Perl 5 Porters list with your show of thanks.
448
449=head1 SEE ALSO
450
451The F<Changes> file for an explanation of how to view exhaustive details on
452what changed.
453
454The F<INSTALL> file for how to build Perl.
455
456The F<README> file for general stuff.
457
458The F<Artistic> and F<Copying> files for copyright information.
459
460=cut