|
|
|
|
|
by supergarfield
1645 days ago
|
|
Letrec requires either laziness (which implies some sort of internal mutability, as thunks get replaced by values at some point), or "internal" mutability that may not be visible to the programmer (like in OCaml, where in a `let rec` some variables will initially be null pointers, and get updated once other definitions have run). In languages with no mutability at all (not even internal mutability like with these two features), you can't create cycles and refcounting becomes possible, but I'm not aware of non-academic general purpose languages that actually fall in this category. Esoteric functional languages like Unlambda do make that guarantee, and implementations can use a ref counter as their GC. I've written more about this here: https://terbium.io/2019/09/cyclic-immutable/ |
|