Provided that everything's immutable, yes, this is the case. A proof of this is
based on ordering of elements: when an element is created, it only refers to things created before it. And since there's no mutability, it can only ever refer things created before it. So no element ever refers to something ahead of itself in the ordering, meaning that there's never a cycle. This changes if you allow for mutable references (things like IORef in Haskell), or if you're doing bad stuff in Native Code. I'd wanted to take advantage of this a while back with an Elm->Rust compiler, that just used Rc (reference counting) for everything, so there's no garbage collection. But that's been put on hold. On Thu, Mar 16, 2017 at 10:06 AM, 'Rupert Smith' via Elm Discuss < [email protected]> wrote: > I am guessing the answer is no. > > type alias Reader { borrowing : List Book } > type alias Book { reader : Maybe Reader } > > newBob = { bob | borrowing = [ warAndPeace ] } > newWarAndPeace = { warAndPeace | reader = Just newBob } > > but the book that bob is borrowing will not have the link back to himself, > as it was only added to the new version. > > Is the Elm heap therefore always cycle free? > > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
