gpt4 book ai didi

haskell - 了解 STG

转载 作者:行者123 更新时间:2023-12-03 02:11:09 25 4
gpt4 key购买 nike

GHC 的设计基于 STG,它代表“无 Backbone 、无标签的 G 机器”。

现在,G-machine 显然是“图缩减机”的缩写,它定义了惰性是如何实现的。未计算的 thunk 被存储为表达式树,执行程序涉及将它们还原为正常形式。 (是一个非循环图,但 Haskell 的普遍递归意味着 Haskell 表达式形成通用,因此是图缩减而不是树缩减。)

不太清楚的是术语“spineless”和“tagless”。

  1. 认为“无脊椎”是指函数应用程序没有函数应用程序节点的“脊椎”。相反,您有一个对象,该对象命名被调用的函数并指向其所有参数。这是正确的吗?

  2. 我认为“无标记”是指构造函数节点没有使用构造函数 ID“标记”,而是使用跳转指令解析 case 表达式。但现在我不确定这是否正确。相反,它似乎指的是节点没有标记其评估状态的事实。谁能澄清这些解释中哪一个(如果有的话)是正确的?

最佳答案

GHC wiki 包含 introductory article about STG作者:马克斯·博林布鲁克:

The STG machine is an essential part of GHC, the world's leadingHaskell compiler. It defines how the Haskell evaluation model shouldbe efficiently implemented on standard hardware. Despite this keyrole, it is generally poorly understood amongst GHC users. Thisdocument aims to provide an overview of the STG machine in its modern,eval/apply-based, pointer-tagged incarnation by a series of simpleexamples showing how Haskell source code is compiled.

关于haskell - 了解 STG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11921683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com