Haskell 在没有堆栈的情况下实现?

发布于 2024-12-16 02:19:45 字数 351 浏览 3 评论 0原文

来自无堆栈语言是如何工作的?

Haskell (as commonly implemented) does not have a call stack; 
evaluation is based on graph reduction.

真的吗?这很有趣,因为虽然我自己从未经历过,但我读过,如果您不使用折叠函数的严格版本,然后强制计算无限折叠,则会出现堆栈溢出。当然,这表明堆栈的存在。谁能澄清一下吗?

from How does a stackless language work?

Haskell (as commonly implemented) does not have a call stack; 
evaluation is based on graph reduction.

Really? That's interesting, because while I've never experienced it myself, I've read that if you don't use the strict versions of the fold functions and then force the evaluation of an infinite fold you get a stack overflow. Surely that indicates the presence of a stack. Can anyone clarify?

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

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

发布评论

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

评论(2

淡淡绿茶香 2024-12-23 02:19:45

我无论如何不是这方面的专家,但我认为您引用的答案并不完全准确。 Haskell 没有大多数命令式语言所具有的直接堆栈,您可以在其中跟踪程序中的调用路径。由于它的惰性,评估是基于图形缩减,您可以在此处阅读有关内容,但最终调用仍然是放置在堆栈中。根据页面,“GHC 中的“堆栈”执行引擎与词法调用堆栈几乎没有相似之处。”所以,是的,有一个堆栈,但它与您在命令式语言中找到的堆栈非常不同,并且它是使用图简化创建的。

I'm not by any means an expert on this, but I think the answer you quoted is not entirely accurate. Haskell doesn't have the straightforward kind of stack most imperative languages have, where you can trace a path of calls through a program. Because of its laziness, evaluation is based on graph reduction, which you can read about here, but calls are still eventually placed in a stack. According to this page, "The “stack“ in GHC's execution engine bears little resemblance to the lexical call stack." So yes, there's a stack, but it's very different from one you would find in an imperative language, and it's created using graph reduction.

救星 2024-12-23 02:19:45

Haskell 并不是“无堆栈”或类似的东西。从 Haskell 源代码生成的代码仍然具有某种符号,并且执行显示一些堆栈跟踪,但它们与源代码的关系非常松散。以下是有关简化调试/跟踪/分析的一些信息:

http: //www.haskell.org/wikiupload/9/9f/HIW2011-Talk-Marlow.pdf

Haskell is not "stackless" or anything like it. Code generated from Haskell source still has some kind of symbols and execution shows some stack traces but they're very loosely related to source code. Here's some information about attempts of simplifying debugging/tracing/profiling:

http://www.haskell.org/wikiupload/9/9f/HIW2011-Talk-Marlow.pdf

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