perldelta - what is new for perl v5.40.0 - Perldoc Browser

submited by
Style Pass
2024-06-10 12:30:04

When using the new class feature, code inside a method, ADJUST block or field initializer expression is now permitted to use the new __CLASS__ keyword. This yields a class name, similar to __PACKAGE__, but whereas that gives the compile-time package that the code appears in, the __CLASS__ keyword is aware of the actual run-time class that the object instance is a member of. This makes it useful for method dispatch on that class, especially during constructors, where access to $self is not permitted.

When using the class feature, field variables can now take a :reader attribute. This requests that an accessor method be automatically created that simply returns the value of the field variable from the given instance.

In Perl 5.36, a deprecation warning was added when downgrading a use VERSION declaration from one above version 5.11, to below. This has now been made a fatal error.

Additionally, it is now a fatal error to issue a subsequent use VERSION declaration when another is in scope, when either version is 5.39 or above. This is to avoid complications surrounding imported lexical functions from builtin. A deprecation warning has also been added for any other subsequent use VERSION declaration below version 5.39, to warn that it will no longer be permitted in Perl version 5.44.

Leave a Comment