与Perl 5相比,Perl 6引入了可选的键入以及约束,例如:
# Perl 5
sub mySub {
my $probability = $_[0];
# Do stuff with $probability
}
# Perl 6 - using optional typing and constraints
sub mySub(Real $probability where 0 < * < 1) {
# Do stuff with $probability
}
是否有研究调查使用这些功能时是否存在性能损失,以及在不同的Perl 6 VM上这些性能损失有多大?
我正在寻找设计合理的跨VM的产品。
最佳答案
Perl 6最完整,设计最完善的性能评估工作是https://github.com/japhb/perl6-bench,但它并不关注可选类型的相对性能。但是,它确实支持多个VM后端,因此它可能是一个不错的起点。
关于performance - 在Perl 6中是否有针对类型/约束的性能惩罚的研究?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42117027/