Perl 5.20与智能匹配的命运又给定了什么时候? [英] Perl 5.20 and the fate of smart matching and given-when?

查看:128
本文介绍了Perl 5.20与智能匹配的命运又给定了什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了Perl 5.18,并且收到了很多这样的警告,

I just installed Perl 5.18, and I get a lot of warnings like this,

given is experimental at .\[...].pl line [...].
when is experimental at .\[...].pl line [...].
Smartmatch is experimental at C:/strawberry/perl/site/lib/[...] line [...].

查看这些警告-我从未在任何地方提到过这些警告-我只能在两个地方找到它,

Looking into these warnings -- which I've never heard mentioned anywhere -- I was only able to find this in two places,

  • perldelta for 5.18, which only really mentions insofar as to say that the feature has been downgraded to experimental?
  • this nntp.perl.org post

对于这些功能所发生的事情,Perl Delta仍然最多能提及,它埋在豆荚的一半位置,

The Perl Delta still does the most to give mention as to what's happening with those features, it's halfway down buried in the the pod,

v5.10.0中添加并在v5.10.1中进行了重大修改的智能匹配一直是人们常抱怨的地方.尽管有很多方法可以使用它,但事实证明,它对Perl的用户和实现者都是有问题和令人困惑的.关于如何最好地解决该问题,已经有许多建议.显然,smartmatch几乎肯定会在未来发生变化或消失.不建议依赖其当前行为.现在,当解析器看到~~,给定或何时发出警告.

Smart match, added in v5.10.0 and significantly revised in v5.10.1, has been a regular point of complaint. Although there are a number of ways in which it is useful, it has also proven problematic and confusing for both users and implementors of Perl. There have been a number of proposals on how to best address the problem. It is clear that smartmatch is almost certainly either going to change or go away in the future. Relying on its current behavior is not recommended. Warnings will now be issued when the parser sees ~~, given, or when.

我对过去10年中Perl最重要的变化该如何撤消感到困惑.我已经开始在各处使用givenwhensmartmatch.是否有关于这些期货的更多信息?谁会发现它们令人困惑"?这些功能可能会如何变化?是否有计划使用模块来实现这些功能?

I'm confused at how the most significant change in Perl in the past 10 years could be pulled. I've started using given, when, and smartmatch all over the place. Is there any more information about these futures? How is anyone finding them "confusing?" How are these features likely to change? Is there a plan to implement these features with a module?

推荐答案

智能匹配的设计存在问题.任何给定的TYPE ~~ TYPE应该做什么的决定通常都是显而易见的,前后矛盾的和/或有争议的.这个想法不是要删除智能匹配;而是要删除智能匹配.是要修复它.

There are problems with the design of smart-matching. The decision of what any given TYPE ~~ TYPE should do is most often unobvious, inconsistent and/or disputed. The idea isn't to remove smart matching; it's to fix it.

具体来说,~~将大大简化,如您在提案中所看到的那样.关于如何匹配两件事的决定将由诸如 Smart :: Match 中已经存在的助手来完成. a>.

Specifically, ~~ will be greatly simplified, as you can see in a proposal by the 5.18 pumpking. Decisions as to how two things should match will be done with helpers such as those that already exist in Smart::Match.

... ~~ any(...)

更具可读性,更灵活(完全可扩展),并解决了许多问题(例如何时应将X视为数字,何时应将其视为字符串?".)

Much more readable, much more flexible (fully extensible), and solves a number of problems (such as "When should X be considered a number, and when should it be considered a string?").

这篇关于Perl 5.20与智能匹配的命运又给定了什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆