Perl: experimental features and Perldoc
I unintentionally used Perl 5.14 the experimental autoderef feature in Perl 5.20 and of course got warnings about its use. Pragma diagnostics
explains how to suppress these warning messages if needed; however, I wanted to know more about the root cause of this warning (and indeed about this feature in general), so I turned to perldoc
to find out more about autoderef
.
The command perldoc experimental
lists a function autoderef
with a high-level instruction on its purpose, but nothing more.
The team perldoc perlexperiment
provides more details on other experimental features but autoderef
is not mentioned at all.
I tried various other options perldoc
(eg -v
, -f
etc.), but to no avail.
What is an efficient way to track messages like this warning
/ diagnostics
using perldoc
? Are experimental traits not included in perldoc
?
UPDATE . See @ThisSuitIsBlackNot's GREAT answer below.
For greater clarity and links: it seems strange that the namespace autoderef
has not been fulfilled in all the various documentation (ie perlexperiment
, perldelta
, perldoc
, etc.). perldoc experiment
named it autoderef
, perldelta5140
designated as auto-deref
. perldoc perlexperiment
used some language from the page perldelta
but not autoderef
or the like.
Since it is diagnostics
stated that related warnings can be suppressed with no warnings "experimental::autoderef"
. It would be nice to use this as a starting point in perldoc
. That is, find relative documentation using perldoc experimental::autoderef
, matching syntax and semantics provided by diagnostics
and / or warnings
.
source to share
When functions are added or removed from the Perl core, they are documented in perldelta
, so if you get a warning about an experimental function, this is a good place to look.
If you know the feature was added in Perl 5.14.0:
perldoc perl5140delta
If not:
grep -lr autoderef $(dirname $(perldoc -l perldelta))
The description you linked to in perl5140delta
is quite detailed, but note that it provides a list of built-in functions that autoderef applies to. Run perldoc -f <function>
to view documentation for built-in functions, eg. perldoc -f push
:
Since Perl 5.14, it
push
can accept a scalarEXPR
that must contain a reference to an unblessed array. The argument will be dereferenced automatically. This aspectpush
is considered highly experimental. The exact behavior may change in a future version of Perl.
The reason for the warning is given in perl5200delta
:
The autoref feature is experimental.
Starting with version 5.1.14, it was possible to use push, pop, keys and other built-in functions not only on aggregate types, but also on their references. This feature was not deployed to its original assigned spec and may now become redundant for postfix dereferencing. It has always been classified as an experimental feature, and in v5.20.0 carries a warning as such.
Indeed, autoderef is mentioned in perlexperiment
, although it is under the heading "Array and hash container functions accept references" (the same heading used in perl5140delta
):
Array and hash container functions accept references
Introduced in Perl 5.14.0
The ticket for this feature is [perl # 119437].
If you browse the online documentation, you can follow the link for issue # 119437 in the Perl Bug Tracking Log, where you can follow development details related to this feature.
In case you were wondering, it looks like autoderef gets axial in the following version:
Feature
autoderef
removedExperimental feature
autoderef
(which allows you to callpush
,pop
,shift
,unshift
,splice
,keys
,values
andeach
the scalar argument) is considered to be unsuccessful. It is now removed; trying to use this feature (or disable a warningexperimental::autoderef
that was previously raised) now throws an exception.
source to share