模板元编程:原始递归?

发布于 2024-12-22 13:37:25 字数 353 浏览 4 评论 0原文

这篇文章中,作者断言:

...该程序确实表明模板实例化机制是一种原始的递归语言,可以在编译时执行重要的计算。

我发现这很有趣,因为我帮助教授计算理论课程,该课程深入研究原始递归函数的理论。然而,我的印象是,模板元编程是图灵完备的,这是一个比说它是原始递归更严格的说法......毕竟,创建一个无法停止的模板元程序并不是很困难。

我错过了什么吗?模板元编程是一种严格原始的递归语言,还是我相信它涵盖更广泛的程序是正确的?

In this article, the writer asserts:

...the program did show that the template instantiation mechanism is a primitive recursive language that can perform nontrivial computations at compile time.

I found this rather interesting, as I help to teach a class in Theory of Computation which delves into the theory of primitive recursive functions. However, I was under the impression that Template Metaprogramming was Turing-complete, which is a strictly stronger statement than to say that it is primitive recursive...And after all, it is not very difficult to create a template metaprogram which fails to halt.

Am I missing something? Is Template Metaprogramming a strictly primitive recursive language, or am I correct in believing it to cover a wider range of programs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别念他 2024-12-29 13:37:25

我相信你只是读了太多的文本,“原始”并不意味着“原始递归”,而是一种“递归语言”(这听起来很奇怪,我称之为将其描述为一种函数式语言,但没关系),这是原始的。

如果您将 TMP 视为一种函数式语言,那么它并不是一种非常复杂的语言;因此,它是一种原始的。

但你是对的,TMP 确实是图灵完备的。

我怀疑很多人都听说过原始递归语言,所以这只是一个不幸的用词。

I believe you just read too much into the text, and the "primitive" is not meant as "primitive recursive", but rather it is a "recursive language" (which sounds odd, I'd call describe that as a functional language, but never mind), which is primitive.

If you look at TMP as a functional language, it is not a very sophisticated one; thus, it is a primitive one.

But you are correct, TMP certainly is Turing-complete.

I doubt many people have heard of primitive recursive languages, and so this is just an unfortunate choice of words.

仅冇旳回忆 2024-12-29 13:37:25

Unruh 的程序仅演示了原始递归,即循环(发生这种情况时我实际上在场!)。然而,人们立即认识到支持完全递归(因为实际上该实现没有进行尾部记录优化)。

Unruh's program only demonstrated primitive recursion, that is, looping (I was actually present when this happened!). However it was immediately recognized that full recursion was supported (because indeed the implementation did not do tail rec optimisation).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文