gpt4 book ai didi

Perl:实验特性和 Perldoc

转载 作者:行者123 更新时间:2023-12-01 01:09:54 25 4
gpt4 key购买 nike

我无意中使用了 Perl 5.14 的实验性 autoderef Perl 5.20 中的功能,当然会收到有关其使用的警告。 diagnostics pragma 解释了如何在需要时抑制这些警告消息;但是,我想了解有关此警告的根本原因(以及真正的整体功能)的更多信息,因此我求助于 perldoc 以了解有关 autoderef 的更多信息。

perldoc experimental 命令列出了 autoderef 功能及其用途的高级声明,但仅此而已。

perldoc perlexperiment 命令提供了有关其他实验性功能的更多详细信息,但根本没有提及 autoderef

我已经尝试了各种其他 perldoc 选项(例如,-v-f 等),但无济于事。

使用 perldoc 追踪此类 warning/diagnostics 消息的有效方法是什么? perldoc 中是否包含实验性功能?

更新:请参阅下面@ThisSuitIsBlackNot 的出色回答。

为了进一步清晰和引用:autoderef 命名空间并没有贯穿所有各种文档(即 perlexperimentperldelta),这似乎很奇怪>、perldoc 等)。 perldoc experiment 称之为autoderefperldelta5140 称之为auto-derefperldoc perlexperiment 使用了 perldelta 页面中的一些语言,但不是 autoderef 等。

由于 diagnostics 声明可以使用 no warnings "experimental::autoderef" 来抑制相关的警告。最好将其用作 perldoc 的起点。也就是说,使用 perldoc experimental::autoderef 查找相关文档,匹配 diagnostics 和/或 warnings 提供的语法和语义。

最佳答案

当向 Perl 核心添加或删除功能时,它们记录在 perldelta 中,因此,如果您收到有关某项功能处于试验阶段的警告,那么这是一个值得关注的地方。

如果您知道该功能是在 Perl 5.14.0 中添加的:

perldoc perl5140delta

如果不是:

grep -lr autoderef $(dirname $(perldoc -l perldelta))

您在 perl5140delta 中链接到的描述本身就相当详尽,但请注意,它给出了 autoderef 适用的内置函数列表。运行 perldoc -f <function>查看内置函数的文档,例如 perldoc -f push :

Starting with Perl 5.14, push can take a scalar EXPR, which must hold a reference to an unblessed array. The argument will be dereferenced automatically. This aspect of push is considered highly experimental. The exact behaviour may change in a future version of Perl.

警告的原因记录在 perl5200delta 中:

The "auto-deref" feature is experimental.

Starting in v5.14.0, it was possible to use push, pop, keys, and other built-in functions not only on aggregate types, but on references to them. The feature was not deployed to its original intended specification, and now may become redundant to postfix dereferencing. It has always been categorized as an experimental feature, and in v5.20.0 is carries a warning as such.

实际上,perlexperiment 中提到了 autoderef ,尽管它位于“数组和散列容器函数接受引用”标题下(与 perl5140delta 中使用的标题相同):

  • Array and hash container functions accept references

    Introduced in Perl 5.14.0

    The ticket for this feature is [perl #119437].

如果您查看 online documentation , 你可以点击链接到 issue #119437在 Perl 的问题跟踪器中,您可以在其中跟踪与该功能相关的开发详细信息。


如果你好奇的话,它看起来像autoderef is getting axed在下一个版本中:

The autoderef feature has been removed

The experimental autoderef feature (which allowed calling push, pop, shift, unshift, splice, keys, values, and each on a scalar argument) has been deemed unsuccessful. It has now been removed; trying to use the feature (or to disable the experimental::autoderef warning it previously triggered) now yields an exception.

关于Perl:实验特性和 Perldoc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31466854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com