看了一眼using perl6 draft,高手指点惊喜在哪里
时间:2010-07-30
来源:互联网
role是动态库?
perl6的最大的特点应该不是这些东西吧
作者: liht1981 发布时间: 2010-07-30
我不愿意说出来,是因为我觉得我的了解还不全面,
仅仅说出一部分怕给别人造成误解而已。
可以摘录一段儿 rakudo star release note 里的内容来回答这个问题:
Some of the many cool Perl 6 features that are available in this release of Rakudo Star:
* Perl 6 grammars and regexes
* formal parameter lists and signatures
* metaoperators
* gradual typing
* a powerful object model, including roles and classes
* lazy list evaluation
* multiple dispatch
* smart matching
* junctions and autothreading
* operator overloading (limited forms for now)
* introspection
* currying
* a rich library of builtin operators, functions, and types
* an interactive read-evaluation-print loop
* Unicode at the codepoint level
* resumable exceptions
There are some key features of Perl 6 that Rakudo Star does not yet handle appropriately, although they will appear in upcoming releases. Thus, we do not consider Rakudo Star to be a "Perl 6.0.0" or "1.0" release. Some of the not-quite-there features include:
* nested package definitions
* binary objects, native types, pack and unpack
* typed arrays
* macros
* state variables
* threads and concurrency
* Unicode strings at levels other than codepoints
* pre and post constraints, and some other phasers
* interactive readline that understands Unicode
* backslash escapes in regex <[...]> character classes
* non-blocking I/O
* most of Synopsis 9
* perl6doc or pod manipulation tools
作者: flw 发布时间: 2010-08-01
就我了解的来说,
* Perl 6 grammars and regexes
* formal parameter lists and signatures
* metaoperators
* a powerful object model, including roles and classes
* lazy list evaluation
* smart matching
* junctions and autothreading
* currying
这些都与很不错的。
其实就算是撇开这些亮点的之外,
就基本的语法结构来说,也大有可圈可点之处,
比如 -> 和 =>,以及和 Perl5 不同的 $@% 的用法规则(在 Perl5 中搞不清楚这些的人可能更加喜欢 Perl6)。
作者: flw 发布时间: 2010-08-01
所以如果恰巧需求是一次需要取两个出来的话,就比较费劲了。
现在的 for 语句就很方便。
for @array -> $a, $b { .......... }
作者: flw 发布时间: 2010-08-01
Bool Bit Int Rat FatRat UInt Num Complex int32 complex64 etc.
Str Cat Blob Char Byte Codepoint Grapheme Buf buf8 buf32 utf8
IO Mu Any Cool Junction Whatever Match
Parcel Capture Signature
Pair Range Set Bag
KeyHash KeySet KeyBag
Scalar Array Hash Code
Enum Order TrigBase
Block Routine Sub
Method Regex
Failure Exception
Instant Duration
Date DateTime
几十种……
作者: flw 发布时间: 2010-08-01
这个特性几乎是其它语言所没有的。用来进行列表之间的运算实在是太方便了。
至于 grammar 和正则表达式则把 Perl 在正则表达式领域的领先程度又推到了一个新的、极高的高度。
恐怕在十年之内不会再有语言能够超逾 Perl6 了。(之前一直是 Perl5 在这个领域保持领先地位)
作者: flw 发布时间: 2010-08-01
作者: flw 发布时间: 2010-08-01
事实 multis 是一组多重分配有关特性的集合:
1, overloading
2, constraints(guard)
3, narrowness
4, parameter pattern
5, 参数绑定检查(is rw)
Perl6 提供特性,向来都是一堆一堆的。十年的功夫不是白费的。
为什么花了十年时间?除了人手问题之外,
就是因为需要设计一个能够优美地包含全部这些语法特性的语言,
并且考虑如何实现它。
作者: flw 发布时间: 2010-08-01
role 相当于 Haskell 的 type class,但这和大多数人认识的 C++/Java 的 class 有所不同,大大的不同。
就 Perl6 目前的设计,简单地来说,你可以把 role 当成是 C++ 的类型系统中的“纯虚类”,
它的作用就是用来约束子类。但是在 Perl6/Haskell 中不这么理解。
顺便说一句,Perl6 的 role 不仅仅可以是编译时的,还可以是运行时的,举个例子:
if %pluggables($0) -> $plug-in {
$self does $plug-in
return "Loaded $0";
}
作者: flw 发布时间: 2010-08-01
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28