Perl6 是否支持依赖类型? [英] Does Perl6 support dependent types?

查看:31
本文介绍了Perl6 是否支持依赖类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近查看了维基百科页面,了解相关类型,我想知道;Perl 6 是否真的引入了依赖类型?我似乎找不到可靠的消息来源.

I was recently looking at the wikipedia page for dependent types, and I was wondering; does Perl 6 actually introduce dependent types? I can't seem to find a reliable source claiming that.

这对某些人来说可能很明显,但对我来说肯定不是很明显.

It might be obvious to some, but it sure as heck ain't obvious to me.

推荐答案

反对 Ven,在 Perl 6 对 SO 问题Is there a language with constrainable types?"的回答之后的评论中,写道 perl6 没有依赖类型"后来在#perl6 的一次交流中写道依赖类型,可能不是,......好吧,如果我们得到可判定的wheres......".(拉里·沃尔的回应是朋友之间有什么问题".顺便说一句,到目前为止,获得有关 Perl 6 的所有问题的权威答案的最佳方法是通过 #perl6 询问 TimToady.)

Against Ven, in the comments following the Perl 6 answer to the SO question "Is there a language with constrainable types?", wrote "perl6 doesn't have dependant types" and later wrote "dependent type, probably not, ... well, if we get decidable wheres..." in an exchange on #perl6. (Larry Wall's response was "what's a few halting problems among friends". Btw, by far the best way to get an authoritative answer on all things Perl 6 is to ask TimToady via #perl6.)

For'dependent-type' SO 标签的摘要是依赖类型是依赖于值的类型."Perl 6 支持依赖于值的类型,所以就是这样.

For The summary for the 'dependent-type' SO tag is "Dependent types are types that depend on values." Perl 6 supports types that depend on values, so there's that.

For Awwaiid 将 Perl 6 添加到维基百科页面 依赖类型 说Perl 6 ...具有不可判定的依赖类型".

For The edit summary for the change by Awwaiid that added Perl 6 to Wikipedia's page on Dependent Types says "Perl 6 ... has undecidable dependent types".

维基百科页面以:

依赖类型是其定义依赖于值的类型.一对整数"是一种类型.一对整数,其中第二个大于第一个"是依赖类型,因为它依赖于值.

a dependent type is a type whose definition depends on a value. A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.

这是在 Perl 6 中按照这些行创建类型的一种方法:

Here's one way to create a type along those lines in Perl 6:

subset LessMorePair of Pair where { $_.key < $_.value }
subset MoreLessPair of Pair where { $_.key > $_.value }

multi sub foo (        Pair) { "  P" }
multi sub foo (LessMorePair) { "LMP" }
multi sub foo (MoreLessPair) { "MLP" }

for 1 => 1, 1 => 2, 2 => 1 { say foo $_ }

#   P
# LMP
# MLP

这是否意味着 Perl 6 subset 特性会生成依赖类型?或许这就是 Awwaiid 的想法.

Does this mean the Perl 6 subset feature generates dependent types? Perhaps this is what Awwaiid is thinking of.

这篇关于Perl6 是否支持依赖类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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