The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

perldelta - what is new for perl v5.37.9

DESCRIPTION

This document describes differences between the 5.37.8 release and the 5.37.9 release.

If you are upgrading from an earlier release such as 5.37.7, first read perl5378delta, which describes differences between 5.37.7 and 5.37.8.

Core Enhancements

New class Feature

A new 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 perlclass. Notes on the internals of its implementation and other related details can be found in 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 experimental::class category. These can be silenced by a no warnings statement.

    use feature 'class';
    no warnings 'experimental::class';

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.

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 #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.

Incompatible Changes

(**{ ... }) removed from the regex engine.

This feature was released as part of 5.37.8, after some use and discussion it was seen as more problematic than understood at first and has been removed in 5.37.9. It was only ever present in a single development release and has never been released as part of a production perl, thus no deprecation cycle has been performed.

Deprecations

Use of ' as a package name separator is deprecated

Using ' 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.

Performance Enhancements

  • Temporary ("mortal") copies are no longer created during context exit for internal static SVs that are in no danger of being prematurely freed. [GH #20800|https://github.com/Perl/perl5/issues/20800]

Modules and Pragmata

Updated Modules and Pragmata

  • autodie has been upgraded from version 2.34 to 2.36.

  • B has been upgraded from version 1.87 to 1.88.

  • Compress::Raw::Bzip2 has been upgraded from version 2.201 to 2.204.

  • Compress::Raw::Zlib has been upgraded from version 2.202 to 2.204.

  • Devel::Peek has been upgraded from version 1.32 to 1.33.

  • Devel::PPPort has been upgraded from version 3.69 to 3.70.

  • experimental has been upgraded from version 0.030 to 0.031.

  • feature has been upgraded from version 1.79 to 1.80.

  • File::Find has been upgraded from version 1.42 to 1.43.

  • IO::Compress has been upgraded from version 2.201 to 2.204.

  • Math::Complex has been upgraded from version 1.6 to 1.61.

  • Memoize has been upgraded from version 1.15 to 1.16.

  • Module::CoreList has been upgraded from version 5.20230120 to 5.20230220.

  • mro has been upgraded from version 1.26 to 1.28.

  • Opcode has been upgraded from version 1.63 to 1.64.

  • parent has been upgraded from version 0.239 to 0.241.

  • Term::Cap has been upgraded from version 1.17 to 1.18.

  • Test::Simple has been upgraded from version 1.302191 to 1.302192.

  • Tie::File has been upgraded from version 1.06 to 1.07.

  • UNIVERSAL has been upgraded from version 1.14 to 1.15.

  • warnings has been upgraded from version 1.61 to 1.62.

Documentation

New Documentation

perlclass

Describes the new class feature.

perlclassguts

Describes the internals of the new class feature.

Changes to Existing Documentation

We have attempted to update the documentation to reflect the changes listed in this document. If you find any we have missed, open an issue at https://github.com/Perl/perl5/issues.

Additionally, the following selected changes have been made:

perlfunc

  • Some wording improvements have been made for the ucfirst, push, unshift and bless functions, as well as additional examples added.

perlvar

  • Added a section on "Scoping Rules of Regex Variables", and other wording improvements made throughout.

Diagnostics

The following additions or changes have been made to diagnostic output, including warnings and fatal error messages. For the complete list of diagnostic messages, see perldiag.

New Diagnostics

New Errors

  • Attempt to bless into a class

    (F) You are attempting to call bless with a package name that is a new-style 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 bless.

  • 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.

  • 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 @ISA array, and the array is not empty. This is not permitted, as it would lead to a class with inconsistent inheritance.

  • Cannot invoke a method of "%s" on an instance of "%s"

    (F) You tried to directly call a 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.

  • Cannot invoke method on a non-instance

    (F) You tried to directly call a 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.

  • Cannot '%s' outside of a 'class'

    (F) You attempted to use one of the keywords that only makes sense inside a class definition, at a location that is not inside such a class.

  • Cannot reopen existing class "%s"

    (F) You tried to begin a class definition for a class that already exists. A class may only have one definition block.

  • Can't bless an object reference

    (F) You attempted to call bless on a value that already refers to a real object instance.

  • can't convert empty path

    (F) On Cygwin, you called a path conversion function with an empty path. Only non-empty paths are legal.

  • Class already has a superclass, cannot add another

    (F) You attempted to specify a second superclass for a class by using the :isa attribute, when one is already specified. Unlike classes whose instances are created with bless, classes created via the class keyword cannot have more than one superclass.

  • 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 not permitted between the attribute name and its value; you must write this as

        class Example::Class :attr(VALUE) ...
  • Class :isa attribute requires a class but "%s" is not one

    (F) When creating a subclass using the class :isa attribute, the named superclass must also be a real class created using the class keyword.

  • Field already has a parameter name, cannot add another

    (F) A field may have at most one application of the :param attribute to assign a parameter name to it; once applied a second one is not allowed.

  • 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 not permitted between the attribute name and its value; you must write this as

        field $var :attr(VALUE) ...
  • 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 method subroutine. This is not permitted, as only methods will have access to the fields of an instance.

  • 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.

  • Only scalar fields can take a :param attribute

    (F) You tried to apply the :param attribute to an array or hash field. Currently this is not permitted.

  • 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.

  • 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 class :isa attribute. This confused the parser.

  • Unrecognized class attribute %s

    (F) You attempted to add a named attribute to a class definition, but perl does not recognise the name of the requested attribute.

  • Unrecognized field attribute %s

    (F) You attempted to add a named attribute to a field definition, but perl does not recognise the name of the requested attribute.

New Warnings

  • ADJUST is experimental

    (S experimental::class) This warning is emitted if you use the ADJUST keyword of use feature 'class'. This keyword is currently experimental and its behaviour may change in future releases of Perl.

  • class is experimental

    (S experimental::class) This warning is emitted if you use the class keyword of use feature 'class'. This keyword is currently experimental and its behaviour may change in future releases of Perl.

  • Method %s redefined

    (W redefine) You redefined a method. To suppress this warning, say

        {
           no warnings 'redefine';
           *name = method { ... };
        }
  • 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.

  • 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.

  • field is experimental

    (S experimental::class) This warning is emitted if you use the field keyword of use feature 'class'. This keyword is currently experimental and its behaviour may change in future releases of Perl.

  • method is experimental

    (S experimental::class) This warning is emitted if you use the method keyword of use feature 'class'. This keyword is currently experimental and its behaviour may change in future releases of Perl.

Changes to Existing Diagnostics

Configuration and Compilation

  • Configure now properly handles quoted elements outputted from gcc. [GH #20606]

  • 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 std:: with using for C++ builds. Since the return types of malloc() and free() are well defined by the C standard, skip probing for them. Configure command-line arguments and hints can still override these type in the unlikely case that is needed. [GH #20806]

Testing

Tests were added and changed to reflect the other additions and changes in this release.

Internal Changes

  • The underlying Perl_dowantarray function implementing the long-deprecated GIMME macro has been marked as deprecated, so that use of the macro emits a compile-time warning. GIMME has been documented as deprecated in favour of GIMME_V since Perl v5.6.0, but had not previously issued a warning.

  • The API function "utf8_length" in perlapi is now more efficient.

Selected Bug Fixes

  • Writing to a magic variables associated with the selected output handle, $^, $~, $=, $- and $%, no longer crashes perl if the IO object has been cleared from the selected output handle. [GH #20733]

  • Redefining a use constant list constant with use constant now properly warns. This changes the behaviour of use constant but is a core change, not a change to constant.pm. [GH #20742]

  • Redefining a use constant list constant with an empty prototype constant sub would result in an assertion failure. [GH #20742]

  • Fixed a regression where the INC method for objects in @INC would not be resolved by AUTOLOAD, while it was in 5.36. The INCDIR method for objects in @INC cannot be resolved by AUTOLOAD as INC would have been resolved first. [GH #20665]

  • $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 $@ into an object will be called consistently. In earlier versions of perl $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.

  • 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 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.

  • The API function "my_snprintf" in perlapi now prints a non-dot decimal point if the perl code it ultimately is called from is in the scope of use locale and the locale in effect calls for that.

Acknowledgements

Perl 5.37.9 represents approximately 4 weeks of development since Perl 5.37.8 and contains approximately 24,000 lines of changes across 360 files from 32 authors.

Excluding auto-generated files, documentation and release tools, there were approximately 8,400 lines of changes to 270 .pm, .t, .c and .h files.

Perl continues to flourish into its fourth decade thanks to a vibrant community of users and developers. The following people are known to have contributed the improvements that became Perl 5.37.9:

Alexander Nikolov, Alex Davies, Andrew Fresh, Aristotle Pagaltzis, Bartosz Jarzyna, Branislav Zahradník, Chad Granum, Craig A. Berry, Dagfinn Ilmari Mannsåker, Dan Jacobson, Elvin Aslanov, Håkon Hægland, Hugo van der Sanden, James E Keenan, Joe McMahon, Jonathan Stowe, Karen Etheridge, Karl Williamson, Kurt Fitzner, Leon Timmermans, Max Maischein, Nicholas Clark, Nicolas R, Paul Evans, Paul Marquess, Renee Baecker, Richard Leach, Scott Baker, Todd Rinaldo, Tomasz Konojacki, Tony Cook, Yves Orton.

The list above is almost certainly incomplete as it is automatically generated from version control history. In particular, it does not include the names of the (very much appreciated) contributors who reported issues to the Perl bug tracker.

Many of the changes included in this version originated in the CPAN modules included in Perl's core. We're grateful to the entire CPAN community for helping Perl to flourish.

For a more complete list of all of Perl's historical contributors, please see the AUTHORS file in the Perl source distribution.

Reporting Bugs

If you find what you think is a bug, you might check the perl bug database at https://github.com/Perl/perl5/issues. There may also be information at http://www.perl.org/, the Perl Home Page.

If you believe you have an unreported bug, please open an issue at https://github.com/Perl/perl5/issues. Be sure to trim your bug down to a tiny but sufficient test case.

If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see "SECURITY VULNERABILITY CONTACT INFORMATION" in perlsec for details of how to report the issue.

Give Thanks

If you wish to thank the Perl 5 Porters for the work we had done in Perl 5, you can do so by running the perlthanks program:

    perlthanks

This will send an email to the Perl 5 Porters list with your show of thanks.

SEE ALSO

The Changes file for an explanation of how to view exhaustive details on what changed.

The INSTALL file for how to build Perl.

The README file for general stuff.

The Artistic and Copying files for copyright information.