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