什么是“全部功能编程"? [英] What is "Total Functional Programming"?

查看:107
本文介绍了什么是“全部功能编程"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

维基百科的意思是:

总功能编程(也 被称为功能强大 编程,与之形成对比 普通的或功能较弱的 编程)是一种编程范例 限制了程序的范围 对于那些可证明的 终止.

Total functional programming (also known as strong functional programming, to be contrasted with ordinary, or weak functional programming) is a programming paradigm which restricts the range of programs to those which are provably terminating.

这些限制意味着总数 函数式编程不是 图灵完成.但是, 仍然可以使用的算法 巨大的.例如,任何算法 具有渐近上限 计算出来的可以是微不足道的 变成了 通过使用可证明终止的功能 上限作为额外参数 每一个递减 迭代或递归.

These restrictions mean that total functional programming is not Turing-complete. However, the set of algorithms which can be used is still huge. For example, any algorithm which has had an asymptotic upper bound calculated for it can be trivially transformed into a provably-terminating function by using the upper bound as an extra argument which is decremented upon each iteration or recursion.

关于《 全部功能编程上的一篇论文,还有Lambda The Ultimate Post.

There is also a Lambda The Ultimate Post about a paper on Total Functional Programming.

直到上周,我才在邮件列表中遇到这个问题.

I hadn't come across that until last week on a mailing list.

您是否知道更多资源,参考资料或示例实现?

Are there any more resources, references or any example implementations that you know of?

推荐答案

如果我正确理解,Total Functional Programming就意味着:用Total Function进行编程.如果我没记错数学课程,则总函数"是在整个域中定义的函数,部分函数"是其定义中带有漏洞"的函数.

If I understood that correctly, Total Functional Programming means just that: Programming with Total Functions. If I remember my math courses correctly, a Total Function is a function which is defined over its entire domain, a Partial Function is one which has "holes" in its definition.

现在,如果您有一个函数,该函数对于某些输入值v进入无限递归或无限循环,或者通常不会以其他某种方式终止,则您的函数未为v定义,因此是部分的,即不是全部.

Now, if you have a function which for some input value v goes into an infinite recursion or an infinite loop or in general doesn't terminate in some other fashion, then your function isn't defined for v, and thus partial, i.e. not total.

总功能编程不允许您编写这样的功能.所有函数始终为所有可能的输入返回结果;然后类型检查器确保是这种情况.

Total Functional Programming doesn't allow you to write such a function. All functions always return a result for all possible inputs; and the type checker ensures that this is the case.

我的猜测是,这大大简化了错误处理:没有任何错误.

My guess is that this vastly simplifies error handling: there aren't any.

您的报价中已经提到了缺点:图灵不完整.例如.操作系统本质上是一个巨大的无限循环.确实,我们不希望操作系统终止运行,我们称这种行为为崩溃",并向我们的计算机大喊大叫!

The downside is already mentioned in your quote: it's not Turing-complete. E.g. an Operating System is essentially a giant infinite loop. Indeed, we do not want an Operating System to terminate, we call this behaviour a "crash" and yell at our computers about it!

这篇关于什么是“全部功能编程"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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