gpt4 book ai didi

pointers - Haskell 运行时如何表示惰性值?

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

我什至不知道如何表达这个问题。假设有一个指向未计算表达式的指针。如果它被请求(通过一些强制它的严格函数),那么指针值将被评估的值替换。正确的?我错了吗?

所以我假设每个指针都有一个标志,说明它是否已被评估。

如果评估是未定义的,比如空列表的头部怎么办? “指针”中存储了什么?

最佳答案

I assume there's a pointer to a non evaluated expression. If it's requested (by some strict function that coerces it) then the pointer value is replaced by the value evaluated. Right? Am I wrong?

这就是它的要点。

So I assume every pointer has a flag stating if it has been evaluated or not.

每个指针都指向某个结构,您可以在其中找到此类信息。

And what if the evaluation is undefined, like the head of an empty list? What is stored in the "pointer"?

指针指向一个表达式,其计算抛出异常。

详细信息在 GHC wiki 的以下页面中;具体参见“对象类型”:https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/rts/storage/heap-objects

数据构造器、函数闭包、thunk(“未计算的表达式”)是主要的。

关于pointers - Haskell 运行时如何表示惰性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63970480/

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