How do Haskell compilers decide whether to allocate on the heap or the stack?

前端 未结 2 2041
北恋
北恋 2021-01-31 04:01

Haskell doesn\'t feature explicit memory management, and all objects are passed by value, so there\'s no obvious reference counting or garbage collection either. How does a Hask

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 04:25

    The only things GHC puts on the stack are evaluation contexts. Anything allocated with a let/where binding, and all data constructors and functions, are stored in the heap. Lazy evaluation makes everything you know about execution strategies in strict languages irrelevant.

提交回复
热议问题