This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5380delta: merge in v5.37.9 delta
authorRicardo Signes <rjbs@semiotic.systems>
Sun, 9 Apr 2023 22:45:58 +0000 (18:45 -0400)
committerRicardo Signes <rjbs@semiotic.systems>
Fri, 2 Jun 2023 01:12:28 +0000 (21:12 -0400)
pod/perl5380delta.pod

index 8d833aa..1fdc715 100644 (file)
@@ -120,6 +120,55 @@ included in a pattern, so that patterns which are O(N) in normal use become
 O(N*N) with a C<(?{ ... })> pattern in them. Switching to C<(*{ ... })> means
 the pattern will stay O(N).
 
+=head2 New C<class> Feature
+
+A new B<experimental> syntax is now available for defining object classes,
+where per-instance data is stored in "field" variables that behave like
+lexicals.
+
+    use feature 'class';
+
+    class Point
+    {
+        field $x;
+        field $y;
+
+        method zero { $x = $y = 0; }
+    }
+
+This is described in more detail in L<perlclass>.  Notes on the internals of
+its implementation and other related details can be found in L<perlclassguts>.
+
+This remains a new and experimental feature, and is very much still under
+development. It will be the subject of much further addition, refinement and
+alteration in future releases.  As it is experimental, it yields warnings in
+the C<experimental::class> category.  These can be silenced by a
+C<no warnings> statement.
+
+    use feature 'class';
+    no warnings 'experimental::class';
+
+=head2 REG_INF has been raised from 65,536 to 2,147,483,647
+
+Many regex quantifiers used to be limited to U16_MAX in the past, but are
+now limited to I32_MAX, thus it is now possible to write /(?:word){1000000}/
+for example.  Note that doing so may cause the regex engine to run longer
+and use more memory.
+
+=head2 New API functions optimize_optree and finalize_optree
+
+There are two new API functions for operating on optree fragments, ensuring
+you can invoke the required parts of the optree-generation process that might
+otherwise not get invoked (e.g. when creating a custom LOGOP).  To get access
+to these functions, you first need to set a C<#define> to opt-in to using
+these functions.
+
+  #define PERL_USE_VOLATILE_API
+
+These functions are closely tied to the internals of how the interpreter
+works, and could be altered or removed at any time if other internal changes
+make that necessary.
+
 =head1 Security
 
 =head1 Incompatible Changes
@@ -176,6 +225,13 @@ string.
 
 =head1 Deprecations
 
+=head2 Use of C<'> as a package name separator is deprecated
+
+Using C<'> as package separator in a variable named in a double-quoted
+string has warned since 5.28.  It is now deprecated in both string
+interpolation and non-interpolated contexts, and will be removed in
+Perl 5.40.
+
 =head1 Performance Enhancements
 
 =over 4
@@ -194,6 +250,12 @@ Creating an anonymous sub no longer generates an C<srefgen> op, the
 reference generation is now done in the C<anoncode> or C<anonconst>
 op, saving runtime.  [github #20290]
 
+=item *
+
+Temporary ("mortal") copies are no longer created during context exit for
+internal static SVs that are in no danger of being prematurely freed.
+[L<GH #20800|https://github.com/Perl/perl5/issues/20800>|https://github.com/Perl/perl5/issues/20800]
+
 =back
 
 =head1 Modules and Pragmata
@@ -260,7 +322,13 @@ XXX Remove this section if Porting/corelist-perldelta.pl did not add any content
 
 =head2 New Documentation
 
-=head3 L<XXX>
+=head3 L<perlclass>
+
+Describes the new C<class> feature.
+
+=head3 L<perlclassguts>
+
+Describes the internals of the new C<class> feature.
 
 =head2 Changes to Existing Documentation
 
@@ -375,6 +443,28 @@ operators.
 
 =back
 
+=head3 L<perlfunc>
+
+=over 4
+
+=item *
+
+Some wording improvements have been made for the C<ucfirst>, C<push>,
+C<unshift> and C<bless> functions, as well as additional examples added.
+
+=back
+
+=head3 L<perlvar>
+
+=over 4
+
+=item *
+
+Added a section on "Scoping Rules of Regex Variables", and other wording
+improvements made throughout.
+
+=back
+
 =head3 L<perlhacktips/Writing safer macros>
 
 =over 4
@@ -437,6 +527,176 @@ L<Execution of %s aborted due to compilation errors.|perldiag/"Execution of %s a
 L<Object with arguments in @INC does not support a hook method
  |perldiag/"Object with arguments in @INC does not support a hook method">
 
+=item *
+
+L<Attempt to bless into a class|perldiag/"Attempt to bless into a class">
+
+(F) You are attempting to call C<bless> with a package name that is a
+new-style C<class>.  This is not necessary, as instances created by the
+constructor are already in the correct class.  Instances cannot be created
+by other means, such as C<bless>.
+
+=item *
+
+L<Cannot assign :param(%s) to field %s because that name is already in use|perldiag/"Cannot assign :param(%s) to field %s because that name is already in use">
+
+(F) An attempt was made to apply a parameter name to a field, when the name
+is already being used by another field in the same class, or one of its
+parent classes. This would cause a name clash so is not allowed.
+
+=item *
+
+L<Cannot create class %s as it already has a non-empty @ISA|perldiag/"Cannot create class %s as it already has a non-empty @ISA">
+
+(F) An attempt was made to create a class out of a package that already has
+an C<@ISA> array, and the array is not empty.  This is not permitted, as it
+would lead to a class with inconsistent inheritance.
+
+=item *
+
+L<Cannot invoke a method of "%s" on an instance of "%s"|perldiag/"Cannot invoke a method of "%s" on
+an instance of "%s"">
+
+(F) You tried to directly call a C<method> subroutine of one class by passing
+in a value that is an instance of a different class.  This is not permitted,
+as the method would not have access to the correct instance fields.
+
+=item *
+
+L<Cannot invoke method on a non-instance|perldiag/"Cannot invoke method on a non-instance">
+
+(F) You tried to directly call a C<method> subroutine of a class by passing
+in a value that is not an instance of that class.  This is not permitted, as
+the method would not then have access to its instance fields.
+
+=item *
+
+L<Cannot '%s' outside of a 'class'|perldiag/"Cannot '%s' outside of a 'class'">
+
+(F) You attempted to use one of the keywords that only makes sense inside
+a C<class> definition, at a location that is not inside such a class.
+
+=item *
+
+L<Cannot reopen existing class "%s"|perldiag/"Cannot reopen existing class "%s"">
+
+(F) You tried to begin a C<class> definition for a class that already exists.
+A class may only have one definition block.
+
+=item *
+
+L<Can't bless an object reference|perldiag/"Can't bless an object reference">
+
+(F) You attempted to call C<bless> on a value that already refers to a real
+object instance.
+
+=item *
+
+L<can't convert empty path|perldiag/"can't convert empty path">
+
+(F) On Cygwin, you called a path conversion function with an empty path.
+Only non-empty paths are legal.
+
+=item *
+
+L<Class already has a superclass, cannot add another|perldiag/"Class already has a superclass, cannot add another">
+
+(F) You attempted to specify a second superclass for a C<class> by using
+the C<:isa> attribute, when one is already specified.  Unlike classes
+whose instances are created with C<bless>, classes created via the
+C<class> keyword cannot have more than one superclass.
+
+=item *
+
+L<Class attribute %s requires a value|perldiag/"Class attribute %s requires a value">
+
+(F) You specified an attribute for a class that would require a value to
+be passed in parentheses, but did not provide one.  Remember that
+whitespace is B<not> permitted between the attribute name and its value;
+you must write this as
+
+    class Example::Class :attr(VALUE) ...
+
+=item *
+
+L<Class :isa attribute requires a class but "%s" is not one|perldiag/"Class :isa attribute requires a class but "%s" is not one">
+
+(F) When creating a subclass using the C<class> C<:isa> attribute, the
+named superclass must also be a real class created using the C<class>
+keyword.
+
+=item *
+
+L<Field already has a parameter name, cannot add another|perldiag/"Field already has a parameter name, cannot add another">
+
+(F) A field may have at most one application of the C<:param> attribute to
+assign a parameter name to it; once applied a second one is not allowed.
+
+=item *
+
+L<Field attribute %s requires a value|perldiag/"Field attribute %s requires a value">
+
+(F) You specified an attribute for a field that would require a value to
+be passed in parentheses, but did not provide one.  Remember that
+whitespace is B<not> permitted between the attribute name and its value;
+you must write this as
+
+    field $var :attr(VALUE) ...
+
+=item *
+
+L<Field %s is not accessible outside a method|perldiag/"Field %s is not accessible outside a method">
+
+(F) An attempt was made to access a field variable of a class from code
+that does not appear inside the body of a C<method> subroutine.  This is not
+permitted, as only methods will have access to the fields of an instance.
+
+=item *
+
+L<Field %s of "%s" is not accessible in a method of "%s"|perldiag/"Field %s of "%s" is not accessible in a method of "%s"">
+
+(F) An attempt was made to access a field variable of a class, from a
+method of another class nested inside the one that actually defined it.
+This is not permitted, as only methods defined by a given class are
+permitted to access fields of that class.
+
+=item *
+
+L<Only scalar fields can take a :param attribute|perldiag/"Only scalar fields can take a :param attribute">
+
+(F) You tried to apply the C<:param> attribute to an array or hash field.
+Currently this is not permitted.
+
+=item *
+
+L<Required parameter '%s' is missing for %s constructor|perldiag/"Required parameter '%s' is missing for %s constructor">
+
+(F) You called the constructor for a class that has a required named
+parameter, but did not pass that parameter at all.
+
+=item *
+
+L<Unexpected characters while parsing class :isa attribute: %s|perldiag/"Unexpected characters while parsing class :isa attribute: %s">
+
+(F) You tried to specify something other than a single class name with an
+optional trailing version number as the value for a C<class> C<:isa>
+attribute.  This confused the parser.
+
+=item *
+
+L<Unrecognized class attribute %s|perldiag/"Unrecognized class attribute %s">
+
+(F) You attempted to add a named attribute to a C<class> definition, but
+perl does not recognise the name of the requested attribute.
+
+=item *
+
+L<Unrecognized field attribute %s|perldiag/"Unrecognized field attribute %s">
+
+(F) You attempted to add a named attribute to a C<field> definition, but
+perl does not recognise the name of the requested attribute.
+
+
 =back
 
 =head3 New Warnings
@@ -467,6 +727,66 @@ L<Filehandle STD%s reopened as %s only for input|perldiag/"Filehandle STD%s reop
 
 L<%s on BEGIN block ignored|perldiag/"%s on BEGIN block ignored">
 
+=item *
+
+L<ADJUST is experimental|perldiag/"ADJUST is experimental">
+
+(S experimental::class) This warning is emitted if you use the C<ADJUST>
+keyword of C<use feature 'class'>.  This keyword is currently
+experimental and its behaviour may change in future releases of Perl.
+
+=item *
+
+L<class is experimental|perldiag/"class is experimental">
+
+(S experimental::class) This warning is emitted if you use the C<class>
+keyword of C<use feature 'class'>.  This keyword is currently
+experimental and its behaviour may change in future releases of Perl.
+
+=item *
+
+L<Method %s redefined|perldiag/"Method %s redefined">
+
+(W redefine) You redefined a method.  To suppress this warning, say
+
+    {
+       no warnings 'redefine';
+       *name = method { ... };
+    }
+
+=item *
+
+L<Odd number of elements in hash field initialization|perldiag/"Odd number of elements in hash field initialization">
+
+(W misc) You specified an odd number of elements to initialise a hash
+field of an object.  Hashes are initialised from a list of key/value
+pairs so there must be a corresponding value to every key.  The final
+missing value will be filled in with undef instead.
+
+=item *
+
+L<Old package separator "'" deprecated|perldiag/"Old package separator "'" deprecated">
+
+(W deprecated, syntax) You used the old package separator "'" in a
+variable, subroutine or package name.  Support for the old package
+separator will be removed in Perl 5.40.
+
+=item *
+
+L<field is experimental|perldiag/"field is experimental">
+
+(S experimental::class) This warning is emitted if you use the C<field>
+keyword of C<use feature 'class'>.  This keyword is currently
+experimental and its behaviour may change in future releases of Perl.
+
+=item *
+
+L<method is experimental|perldiag/"method is experimental">
+
+(S experimental::class) This warning is emitted if you use the C<method>
+keyword of C<use feature 'class'>.  This keyword is currently
+experimental and its behaviour may change in future releases of Perl.
+
 =back
 
 =head2 Changes to Existing Diagnostics
@@ -612,6 +932,12 @@ C<qr/\@INC[ \w]+:/> instead of using C<qr/\@INC contains:/> or
 C<qr/\@INC entries checked:/> in tests as this will ensure both forward
 and backward compatibility.
 
+=item *
+
+L<Old package separator used in string|perldiag/"Old package separator used in string">
+
+This diagnostic is now also part of the C<deprecated> category.
+
 =back
 
 =head1 Utility Changes
@@ -673,6 +999,22 @@ C<I32>/C<U32> formatting symbols added in 5.37.2, C<I32df>, C<U32xf>, etc.
 used to be defined in F<perl.h> using preprocessor conditionals.
 They are now determined in F<Configure> and defined in F<config.h>.
 
+=item *
+
+C<Configure> now properly handles quoted elements outputted from gcc. [L<GH #20606|https://github.com/Perl/perl5/issues/20606>]
+
+=item *
+
+C<Configure> probed for the return type of malloc() and free() by
+testing whether declarations for those functions produced a function
+type mismatch with the implementation.  On Solaris, with a C++
+compiler, this check always failed, since Solaris instead imports
+malloc() and free() from C<std::> with C<using> for C++ builds.  Since
+the return types of malloc() and free() are well defined by the C
+standard, skip probing for them.  C<Configure> command-line arguments
+and hints can still override these type in the unlikely case that is
+needed.  [L<GH #20806|https://github.com/Perl/perl5/issues/20806>]
+
 =back
 
 =head1 Testing
@@ -1041,6 +1383,19 @@ Added HvNAMEf and HvNAMEf_QUOTEDPREFIX special formats. They take an HV *
 as an argument and use C<HvNAME()> and related macros to determine the string,
 its length, and whether it is utf8.
 
+=item *
+
+The underlying C<Perl_dowantarray> function implementing the
+long-deprecated L<C<GIMME>|perlapi/GIMME> macro has been marked as
+deprecated, so that use of the macro emits a compile-time warning.
+C<GIMME> has been documented as deprecated in favour of
+L<C<GIMME_V>|perlapi/GIMME_V> since Perl v5.6.0, but had not
+previously issued a warning.
+
+=item *
+
+The API function L<perlapi/utf8_length> is now more efficient.
+
 =back
 
 =head1 Selected Bug Fixes
@@ -1169,6 +1524,67 @@ overloaded object have been fixed. The FETCH method should only be
 called once, but prior to this release was actually called twice.
 L<[GH #20574]|https://github.com/Perl/perl5/pull/20574>
 
+=item *
+
+Writing to a magic variables associated with the selected output
+handle, C<$^>, C<$~>, C<$=>, C<$-> and C<$%>, no longer crashes perl
+if the IO object has been cleared from the selected output
+handle. [L<GH #20733|https://github.com/Perl/perl5/issues/20733>]
+
+=item *
+
+Redefining a C<use constant> list constant with C<use constant> now
+properly warns.  This changes the behaviour of C<use constant> but is
+a core change, not a change to F<constant.pm>.  [L<GH #20742|https://github.com/Perl/perl5/issues/20742>]
+
+=item *
+
+Redefining a C<use constant> list constant with an empty prototype
+constant sub would result in an assertion failure.  [L<GH #20742|https://github.com/Perl/perl5/issues/20742>]
+
+=item *
+
+Fixed a regression where the C<INC> method for objects in C<@INC>
+would not be resolved by C<AUTOLOAD>, while it was in 5.36.  The
+C<INCDIR> method for objects in C<@INC> cannot be resolved by
+C<AUTOLOAD> as C<INC> would have been resolved first.  [L<GH #20665|https://github.com/Perl/perl5/issues/20665>]
+
+=item *
+
+C<$SIG{__DIE__}> will now be called from eval when the code dies during
+compilation regardless of how it dies. This means that code expecting to
+be able to upgrade C<$@> into an object will be called consistently. In
+earlier versions of perl C<$SIG{__DIE__}> would not be called for
+certain compilation errors, for instance undeclared variables. For other
+errors it might be called if there were more than a certain number of
+errors, but not if there were less. Now you can expect that it will be
+called in every case.
+
+=item *
+
+Compilation of code with errors used to inconsistently stop depending on
+the count and type of errors encountered. The intent was that after 10
+errors compilation would halt, but bugs in this logic meant that certain
+types of error would be counted, but would not trigger the threshold
+check to stop compilation. Other errors would. With this release after
+at most 10 errors compilation will terminate, regardless of what type of
+error they were.
+
+Note that you can change the maximum count by defining
+C<PERL_STOP_PARSING_AFTER_N_ERRORS> to be something else during the
+configuration process. For instance
+
+    ./Configure ... -Accflags='-DPERL_STOP_PARSING_AFTER_N_ERRORS=100'
+
+would allow up to 100 errors.
+
+=item *
+
+The API function L<perlapi/my_snprintf> now prints a non-dot decimal
+point if the perl code it ultimately is called from is in the scope of
+C<use locale> and the locale in effect calls for that.
+
+
 =back
 
 =head1 Known Problems